Searches for a pattern in the input string and replaces either the first match or every match with a substring you specify.
This node performs more quickly than Search and Replace Regular Expression but gives you fewer options for matching strings. For example, Search and Replace Pattern does not support the parenthesis or vertical bar (|) characters.
String on which the node operates.
The pattern you want to search for and replace. This input is limited to the following regular expression characters: . (period), *, +, ?, [], ^, $, \, \b, \f, \n, \s, \r, \t, and \xx. Furthermore, this input does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification.
Definitions of Special Characters
String that replaces the search pattern in the input string.
Definitions of Special Characters
Use the following special characters in replace string.
Special Character | Description | Example(s) |
---|---|---|
$n or ${n} | Inserts a string you specify before or after the submatch you specify. Refer to the Specifying Backreferences in replace string section below for more information about using backreferences in replace string. Use ${n} if you have more than nine submatches in a regular expression and want to refer to a submatch after the ninth. $12 inserts only the first submatch because the function reads only the first digit that immediately follows $. However, ${12} inserts the twelfth submatch. |
Input String: Welcome LabVIEW! Pattern: (LabVIEW) Replace String: to $1! Result: Welcome to LabVIEW! |
Input String: Welcome to the LabVIEW Help! Pattern: We(l)(co(m)e)( )(to)( )t(he) (Lab)(VIE(W)) He(lp)(!) Replace String: $7${11}ful${12} Result: helpful! |
||
\$n | Cancels the interpretation of any special character you use in replace string. | Input String: total=123 per day Pattern: (\d+)(per \w*)? Replace String: \$$1$2 Result: total=$123 per day As in this example, use \$ to insert the literal character $. Use \\ to indicate a literal backslash. |
Specifying Backreferences in replace string
You can specify a backreference in replace string that refers to submatches in the input string. Use $1 to refer to the first submatch, $2 to refer to the second submatch, and so on. Consider the following example:
Input String: $value "TRUE"TRUE" *NULL
Pattern: (["*$])(\w+)\1\2\1
Replace String: $1$2value$1
Result: $value "TRUEvalue" *NULL
Number of characters into the input string at which the node starts searching for a match. If offset is less than or equal to 0, the node starts searching at the beginning of the input string.
Default: 0
String that this node produces after operating on the input string.
Index in string of the first character after the last match. If the node does not find a match, offset past match is -1.
If the node does not find pattern, result string returns an empty string and offset past match returns -1.
Characters in UTF-8 can be multiple bytes so string nodes count the number of characters in a string instead of jumping to a point in memory. Since the length and offset parameters are in units of characters, avoid nesting this node with large strings because that can create exponential functions that carry a higher performance burden.
Where This Node Can Run:
Desktop OS: Windows
FPGA: Not supported
Web Server: Not supported in VIs that run in a web application