Regular expression to replace String
- Last Updated: October 26, 2026
- 2 minute read
- Corticon.js
- Version 2.4
- Documentation
SYNTAX
<String>.regexReplaceString(regularExpression,replacementString)
<String>.regexReplaceString(regularExpression,replacementString,regexFlag:<String>)
DESCRIPTION
Returns a new String where the strings matching the regular expression are replaced by the replacement string.
Note: Regular expressions are a well-established technique that uses a sequence of characters to define a search pattern. For more information, see Wikipedia, as well one of the many sites that provide examples, such as regular-expresssions.info, and others that analyze the expressions you create.
FLAGS
The characters gis, when one or more are added to the expression with no separator, represent:
gglobal, replace more than first match (the default)iignore casesmatch line terminator ("newline") characters in a string, which it would not match otherwise. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll.
USAGE RESTRICTIONS
The Operators row of the table in Summary Table of Vocabulary Usage Restriction applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses regexReplaceString in non-conditional actions as follows:
regexReplaceString("[0-9]", "X")regexReplaceString(" {2,}", " "): Replace all instances of digits with the character X- Replace all instances of multiple spaces with a single spaceregexReplaceString("[aeiou]", ".")- Replace all vowels with a dot.regexReplaceString("[^aeiou]", ".") - Replace all non-vowel characters with a dot.regexReplaceString("[c-v]", ".")- Replace each character in the range from c to v with a dot.regexReplaceString('^[ \t]+|[ \t]+#39;, '')- Strip off leading and trailing spaces.
![]()
SAMPLE RULETEST
A sample Ruletest shows the regexReplaceString effect in output.
![]()