Searches for a pattern of characters in a string as specified by a regular expression. If this node finds a match, it splits the string into three substrings and any number of submatches. Resize the node to view additional submatches found in the string.
This node does not support null characters in strings. If you include null characters in strings you wire to this node, the node returns an error and may return unexpected results.
This node performs more slowly than Match Pattern but gives you more options for matching strings. For example, Match Regular Expression supports the parenthesis and vertical bar (|) characters.
A Boolean value that determines whether to treat the text in the input string as a multiple-line string. This affects how the ^ and $ characters handle matches.
True | ^ matches the beginning of any line in the input string. $ matches the end of any line in the input string. |
False | ^ matches only the beginning of the input string. $ matches only the end of the input string. |
Default: False
The string that this node searches. This string cannot contain null characters.
The pattern you want to search for in the input string. This string cannot contain null characters. Use Perl Compatible Regular Expressions to refine searches.
Definitions of Regular Expressions
Use the following regular expressions to search the input string.
To anchor a match at the beginning and end of a string, use ^ as the first character in a pattern and $ as the last character of a pattern. For example, ^LabVIEW$ matches LabVIEW in LabVIEW but not in LabVIEW! or Hello LabVIEW. Anchoring the match at the beginning and end of the string requires the whole string to match.
Specifying Backreferences in the Search String
Use backreferences to refer to previous submatches within the same regular expression. You can use backreferences to create a submatch using a character group in one part of an expression and then match that exact submatch in a later part of the expression.
To specify a backreference, use \1 to refer to the first submatch, \2 to refer to the second, and so on. For example, consider the following regular expression:
(["*$])(\w+)\1\2\1
The first character group contains a character class that matches ", *, or $. The second character group matches one or more word characters. The first backreference, \1, matches the same submatch as the first character group, (["*$]). The second backreference, \2, matches the same submatch as the second character group, (\w+). The third backreference, \1, is identical to the first backreference and matches the same submatch as the first character group.
This example matches strings such as "foo"foo", *bar*bar*, and $baz$baz$, but does not match strings such as "foo$foo" or "foo*bar".
The number of characters into the input string at which this node starts searching.
The offset of the first character in the input string is 0. If offset is beyond the end of the input string, this node returns an empty string.
Error conditions that occur before this node runs.
The node responds to this input according to standard error behavior.
Standard Error Behavior
Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.
Default: No error
A string that contains all the characters in input string that occur before the match. If the node does not find a match, this string contains all of the characters in the input string.
All the characters that match the expression entered in regular expression. Any substring matches the node finds appear in the submatch outputs. If this node does not find a match, whole match contains an empty string.
All the characters after the match. If the node does not find a match, after match contains an empty string.
Index of the first character after the last match the node finds in the input string. If the node does not find a match, offset past match returns -1.
Error information.
The node produces this output according to standard error behavior.
Standard Error Behavior
Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.
Portion of the whole match you capture using character grouping in the regular expression. Capture a submatch by placing parentheses around the portion of a regular expression you want the node to return as a submatch.
For example, the regular expression (el.)..(L..) returns two submatches in the input string Hello LabVIEW!. Each submatch corresponds to a character group in the order that the character group appears in the regular expression. In this example, submatch 1 is ell and submatch 2 is Lab.
Submatch Behavior with Nested Character Groups
If you nest a character group within another character group, the regular expression creates a submatch for the outer group before the inner group. For example, the regular expression (.(el.).).(L..) returns three submatches in the input Hello LabVIEW!: Hello, ell, and Lab. In this example, submatch 1 is Hello because the regular expression matches the outer character group before the inner group.
Grouped Regular Expression | Rewritten Expression |
(.|\s)*A | (?s).*A or [^A]*A |
(a*)* | a* |
If the node does not find a match, whole match and after match contain empty strings, before match contains the entire input string, offset past match returns -1, and all submatch outputs return empty strings. Place any substrings you want to search for in parentheses. This node returns any substring expressions it finds in submatch 1..n.
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