Replace information in a string.
This replaces all occurrences of regexp in input with new-substring. If count: is specified, it replaces only the first count occurrences of regexp. (This is different from Perl, which replaces only the first occurrence unless /g is specified) New-substring can contain back-references to the regexp. For instance,
regexp-replace("The rain in Spain and some other text",
"the (.*) in (\\w*\\b)", "\\2 has its \\1")returns “Spain has its rain and some other text”. If the subgroup referred to by the back-reference was not matched, the reference is interpreted as the null string. For instance,
regexp-replace("Hi there", "Hi there(, Bert)?",
"What do you think\\1?")returns “What do you think?” because “, Bert” wasn’t found.
| input | An instance of <string>. The string to parse and replace pieces of. |
| regexp | An instance of <string>. |
| new-substring | An instance of <string>. The replacement string. |
| count: | An instance of <integer> or #f. If supplied, number of substitutions to make. The default is #f. |
| case-sensitive: | An instance of <object>. If true, match case in regexp while parsing. The default is #f. |
| start: | An instance of <integer>. Where to start parsing the string. The default is 0. |
| end: | An instance of <integer> or #f. If defined, where to stop parsing the string. The default is #f. |
| changed-string | An instance of <string>. |