Searches for the first string, and replaces it with the second. This differs from the REPLACE() function used outside of the regex object.
| Category: | Regular Expression |
| Returned data type: | String |
specifies a string value in which you want to search for and replaced in the pattern defined by your compiled regular expression. This can be an explicit string ("MyValue"). This can also be a variable already defined in your expression code or passed to your expression node as a column from a previous node (MyValue or "My Value").
| Requirement | input-string must not be NULL or blank. |
specifies a string to replace input-string that was matched by the compiled regular expression.
//Define two string variables
string MyString
string MyNewString
// Provide a value for MyString
MyString = "12Flux"
// Defined a regular expression object variable
regex r
// Compile a regular expression that will look for a series of digits
// either 2 or 3 digits long
r. compile("\d{2,3}")
// Use the replace function to place "Data" in place of the found
// pattern and save that in a new string variable.
// If you change MyString to 1234 or 12345 you can see the
// difference in how the pattern is found
MyNewString = r.replace(MyString,"Data")
// Terminate the expression node processing
seteof()