Special Characters for Match Pattern

Use the following special characters in the regular expression input of the Match Pattern function.

Note  The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification. Instead of the Match Pattern function, use the Match Regular Expression function for more complex pattern matching.
Special CharacterDescriptionExample(s)
.
(period)
Matches any single character except a newline character. Within square brackets, . is literal. string: Welcome to LabVIEW.
regular expression: t....
match substring: to La

If you input [z.] as the regular expression, the period is literal and matches either . or z. In this example, [z.] returns . as the match.
* Marks the single preceding character or character class as one that can appear zero or more times in the input. Because an asterisk can match a pattern that appears zero times, regular expressions that include an asterisk can return an empty string if the whole pattern is marked with an asterisk. This quantifier matches as many characters as possible. string: Hello LabVIEW!
regular expression: el*
match substring: ell

Expressions such as w* or (welcome)* match an empty string if the function finds no other matches.
+ Marks the single preceding character or character class as one that can appear one or more times in the input. This quantifier matches as many characters as possible. string: Hello LabVIEW!
regular expression: el+
match substring: ell
? Marks the single preceding character or character class as one that can appear zero or one time in the input. This quantifier matches as many characters as possible by default. string: Hello LabVIEW!
regular expression: el?
match substring: el
[] Creates a character class, which allows you to match any one of a set of characters that you specify. For example, [abc] matches a, b, or c. The Match Pattern function interprets special characters inside square brackets literally, with the following exceptions:
-(dash) Indicates a range when used between digits, or lowercase or uppercase letters; for example, [0-5], [a-g], or [L-Q].
~ Matches any character, including non-displayable characters, except for the characters or range of characters in brackets. For example, [~0-9] matches any character other than 0 through 9.
^ Matches any displayable character, including the space character, except the characters or range of characters enclosed in the brackets. For example, [^0-9] matches all displayable characters, including the space character, except 0 through 9.
string: version=14.0.1
regular expression: [0-9]+\.[0-9]+\.[0-9]+
match substring: 14.0.1

The expression [0-9] matches any digit. The plus sign matches the previous character class, [0-9], one or more times but as many times as possible. The expression \. matches a literal . character. The plus sign matches the previous character class, [0-9], one or more times but matches as many times as possible. You can use this regular expression to match a three-part version number.
^ If ^ is the first character of regular expression, it anchors the match to the offset in string. The match fails unless regular expression matches that portion of string that begins with the character at offset. If ^ is not the first character, it is treated as a regular character. string: Hello LabVIEW!
regular expression: ^[^ ]+
match substring: Hello

From the beginning of the input string, this regular expression matches as many characters—other than a space character—as possible. You can use this regular expression to isolate the first word, numeral, or other character combination of a string.
$ If $ is the last character of regular expression, it anchors the match to the last element of string. The match fails unless regular expression matches up to and including the last character in the string. If $ is not last, it is treated as a regular character. string: Hello LabVIEW!
regular expression: [^ ]+$
match substring: LabVIEW!

From the end of the input string, this regular expression matches as many characters—other than a space character—as possible. You can use this regular expression to isolate the last word, numeral, or other character combination of a string.
\ Cancels the interpretation of any special character in this list. For example, \? matches a question mark, \. matches a period, and \\ matches a backslash. You also can use the following constructions for the space and non-displayable characters:
\b backspace
\f form feed
\n newline
\s space
\r carriage return
\t tab
\xx any character, where xx is the hex code using 0 through 9 and upper case A through F
string: Welcome
       to   the LabVIEW Help!

regular expression: come\nto\tthe\sLabVIEW\sHelp\21
match substring:  come
                 to   the LabVIEW Help!


The expression come\n matches the literal letters followed by a newline character. The expression to\t matches the literal characters to followed by a tab. The two \s expressions match the spaces between the and LabVIEW and LabVIEW and Help!. The expression \21 matches the exclamation point because 21 is the hexadecimal code for an exclamation point.

Related Information

Match Pattern Function

Match Regular Expression Function