Replace text in a string based on regular expressions.
StringRegExpReplace ( "test", "pattern", "replace", [ count ] )
Parameters
| test | The string to check |
| pattern | The regular expression to compare. See StringRegExp for pattern definition characters. |
| replace | The text to replace the regular expression matching text with. To insert matched group text, \0 - \9 (or $0 - $9) can be used as back-references. |
| count | [optional] The number of times to execute the replacement in the string. The default is 0. Use 0 for global replacement. |
Return Value
| @Error | Meaning |
| 0 | Executed properly. Check @Extended for the number of replacements performed. |
| 2 | Pattern invalid. @Extended = offset of error in pattern. |
Remarks
To separate back-references from actual (replaced) numbers, wrap it with half-round brackets, i.e: "${1}5".
Related
StringReplace, StringRegExp
Example
MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace("Where have all the flowers gone, long time passing?", "[aeiou]", "@"))