User Tools

Site Tools


syntax:functions:regexreplace

This is an old revision of the document!


RegExReplace(text, replace_text, regex_text)

Category: Text function


Description

This function replaces the first substring within text that matches the regular expression pattern (regex_text) with the given replacement string, replace_text.


Use cases

RegExMatch is useful for fuzzy-matching and replacing substrings of text using a specific pattern of characters.


Arguments

ArgumentTypeDescription
textTextThe text value to test for the regex_text RegEx pattern.
replace_textTextThe text value to replace any text found that matches the regex_text RegEx pattern.
regex_textText (RegEx pattern)The string pattern to search for within text. The first instance of any text matching this pattern
is replaced with replace_text.

Return value type: Text


Examples

regexreplace('12345678', 'ABCD', '^\d{4}') //Returns 'ABCD5678'
regexreplace('MaryAnne', 'Jo', '[a-zA-Z]{4}') //Returns 'JoAnne'


See also

syntax/functions/regexreplace.1629090261.txt.gz · Last modified: 2021/08/16 01:04 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki