replace$
Syntax
result = replace$ (startpos, string_or_tag, string_to_be_replaced, string_to_be_entered, options)
Arguments
result, string_or_tag, string_to_be_replaced, string_to_be_entered: text
startpos: numeric
options: 1, 2, 4, or 8 (see table below)
Meaning
This function replaces a (series of) character(s) by another character or series of characters in a string or tag, and searches towards it from character number startpos. The result of the replace action (the altered string) is put in result.
options (numeric):
1 |
Replace all occurrences of string_to_be_replaced. |
2 |
Ignore uppercase and lowercase distinctions. |
4 |
Replace whole words only. |
8 |
Replace string_to_be_replaced only if it fills the entire field. |
You can run several options at once by adding them and just entering their sum as one option. All options, except 1, replace only the first encountered string_to_be_replaced: if you'd like all occurrences of the string_to_be_replaced to be replaced, use 1.
Examples
result = replace$ (1, U1, '\\', '/', 1)
/* replaces all single backslashes with forwardslashes in field U1: for this function, backslashes (or single quotes) need to be escaped by doubling them;
result = replace$(1, searchValue, '''', '''''', 1)
/* replaces all single quotes with two single quotes in text variable searchValue: for this function, single quotes (or backslashes) need to be escaped by doubling them;
result = replace$ (1, TI[1], 'The', '', 6)
/* replaces 'The' as a whole word with nothing, and ignore case;
result = replace$ (1, SA, '\n', '<br>', 1)
/* replaces \n (new line) with an HTML break-tag