Match Regular Expression function: Difference between revisions
Appearance
m Category: String Palette |
Added input parameters |
||
| Line 1: | Line 1: | ||
{{ | {{LabVIEW Palette Object Information|palette=Functions Palette/Programming/String{{!}}String palette|type=function|icon=String Palette - Match Regular Expression.png}} | ||
The '''Match Regular Expression function'''... | The '''Match Regular Expression function''' searches for a regular expression in the '''input string''' beginning at the '''offset''' you enter. If the function finds a match, it splits the string into three substrings and any number of submatches. Resize the function to view any submatches found in the string. | ||
{{TOCright}} | |||
== Usage == | |||
[[File:Match Regular Expression function.png|center]] | |||
== | {| class="wikitable" | ||
|+ Parameters | |||
! Data Type | |||
! Name | |||
! Required? | |||
! Description | |||
|- | |||
! [[File:Boolean.png|link=Boolean data type]] | |||
| '''multiline?''' | |||
| No | |||
| '''multiline?''' specifies whether to treat the text in '''input string''' as a multiple-line string. This setting affects how the ^ and $ characters handle matches. | |||
*If you set '''multiline?''' to FALSE (default), when you enter ^ at the beginning of a regular expression, the expression matches only the beginning of the string in '''input string'''. When you enter $ at the end of a regular expression, the expression matches only the end of the string in '''input string'''. | |||
*If you set '''multiline?''' to TRUE, ^ matches the beginning of any line in '''input string''' and $ matches the end of any line in '''input string'''. | |||
|- | |||
! [[File:Boolean.png|link=Boolean data type]] | |||
| '''ignore case?''' | |||
| No | |||
| '''ignore case?''' specifies whether the string search is case sensitive. If FALSE (default), the string search is case sensitive. | |||
|- | |||
! [[File:String.png|link=String data type]] | |||
| '''input string''' | |||
| Yes | |||
| '''input string''' specifies the input string the function searches. This string cannot contain null characters. | |||
|- | |||
! [[File:String.png|link=String data type]] | |||
| '''regular expression''' | |||
| Yes | |||
| '''regular expression''' specifies the pattern you want to search for in '''input string'''. If the function 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 submatches outputs return empty strings. Place any substrings you want to search for in parentheses. The function returns any substring expressions it finds in '''substring 1..n'''. This string cannot contain null characters. | |||
|- | |||
! [[File:I32 Array.png|link=I32 data type]] | |||
| '''offset''' | |||
| No | |||
| '''offset''' specifies the number of characters into '''input string''' at which the function starts searching for '''search string'''. | |||
|- | |||
! [[File:Error Cluster.png|link=Error Cluster data type]] | |||
| '''error in''' | |||
| No | |||
| '''error in''' describes error conditions that occur before this node runs. This input provides [[Error Cluster data type|standard error]] in functionality. | |||
|} | |||
== Best practice == | == Best practice == | ||
Revision as of 14:13, 1 February 2021
| Object information | |
|---|---|
| Owning palette(s) | String palette |
| Type | Function |
| Requires | Basic Development Environment |
| Icon | |
The Match Regular Expression function searches for a regular expression in the input string beginning at the offset you enter. If the function finds a match, it splits the string into three substrings and any number of submatches. Resize the function to view any submatches found in the string.
Usage

| Data Type | Name | Required? | Description |
|---|---|---|---|
| multiline? | No | multiline? specifies whether to treat the text in input string as a multiple-line string. This setting affects how the ^ and $ characters handle matches.
| |
| ignore case? | No | ignore case? specifies whether the string search is case sensitive. If FALSE (default), the string search is case sensitive. | |
| input string | Yes | input string specifies the input string the function searches. This string cannot contain null characters. | |
| regular expression | Yes | regular expression specifies the pattern you want to search for in input string. If the function 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 submatches outputs return empty strings. Place any substrings you want to search for in parentheses. The function returns any substring expressions it finds in substring 1..n. This string cannot contain null characters. | |
| offset | No | offset specifies the number of characters into input string at which the function starts searching for search string. | |
| error in | No | error in describes error conditions that occur before this node runs. This input provides standard error in functionality. |
Best practice
Tips and tricks
- Use back references to refer to previous partial matches in a regular expression.
\1refers to the first partial match,\2to the second, and so on. For example,(cat|dog) \1matches "cat cat" or "dog dog" but not "cat dog" or "dog cat".