Match Pattern Function

Owning Palette: String Functions

Requires: Base Development System

Searches for regular expression in string beginning at offset. If the function finds a match, it splits string into three substrings. A regular expression requires a specific combination of characters for pattern matching. This function gives you fewer options for matching strings but performs more quickly than the Match Regular Expression function.

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. You can use a specific set of special characters to refine the search. The connector pane displays the default data types for this polymorphic function.

Details  

 Add to the block diagram  Find on the palette
string specifies the input string you want the function to search.
regular expression is the pattern for which you want to search in string. If the function does not find regular expression, match substring returns an empty string, before substring returns the entire string, after substring returns an empty string, and offset past match returns –1.
offset specifies number of characters into string at which the function starts searching for a match. offset must be numeric. The offset of the first character in string is 0. If offset is unwired or less than 0, the function takes offset as 0.
before substring returns a string containing all the characters before the match.
match substring is the matched string.
after substring contains all characters following the matched pattern.
offset past match returns the index in string of the first character of after substring. If the function does not find a match, offset past match is –1. The offset input and the offset past match output might be equal when the empty string is a valid match for the regular expression. For example, if regular expression is b* and the string input is cdb, offset past match is 0. If string is bbbcd, offset past match is 3.

Match Pattern Details

This function is similar to the Search and Replace Pattern VI. The Match Pattern function gives you fewer options for matching strings but performs more quickly than the Match Regular Expression function. For example, the Match Pattern function does not support the parenthesis or vertical bar (|) characters.

The following table shows examples of regular expressions you can use with this function. Some of these examples use special characters to refine the search.

Note  If you want to include special characters in the search string, you must enclose each special character in brackets. For example, to search for the string hz+, enter hz[+] in regular expression. Otherwise, LabVIEW uses the special character to refine the search.
Characters to Find Regular Expression
VOLTS VOLTS
All uppercase and lowercase versions of volts, that is, VOLTS, Volts, volts, and so on [Vv][Oo][Ll][Tt][Ss]
A space, a plus sign, or a minus sign [ +-]
A sequence of one or more digits [0-9]+
Zero or more spaces [\s*] or [ *] (that is, a space followed by an asterisk)
One or more spaces, tabs, new lines, or carriage returns [\t \r \n \s]+
One or more characters other than digits [~0-9]+
The word Level only if it begins at the offset position in the string ^Level
The word Volts only if it appears at the end of the string Volts$
The longest string within parentheses (.*)
The longest string within parentheses but not containing any parentheses within it ([~()]*)
A left bracket \[
A right bracket \]
cat, dog, cot, dot, cog, and so on. [cd][ao][tg]