Match Pattern Returns Wrong Index

Updated May 3, 2018

Reported In

Software

  • LabVIEW

Issue Details

When using the Match Pattern VI with "123456.78" as input string searching for ".", the offset past match output returns 1 (and not 7).

Solution

The Search and Replace Pattern.vi, the Match Regular Expression node, and the Match Pattern node interpret the pattern wired to them as a Regular Expression (also regex or regexp). The period is a special character in regex matching and needs to be escaped to be interpreted as a period. Use "\." instead of ".".


 

Additional Information

Regular Expressions

A Regular Expression is a sequence of characters that can define more specific searches compared to simple string comparisons.
Examples:
  • "\.[a-z]" matches any full stop followed by any lower-case letter between a and z.
  • "(?<=\.) {2,}(?=[A-Z])": At least two spaces are matched, but only if they occur directly after a period (.) and before an upper case letter.
 

Search and Replace String node

The Search and Replace String node can use both a regex and a normal string search: Right-click it to toggle between them. Notice the small asterisk (*) appearing on the node's icon when it is set to Regular Expression mode:

WAS THIS ARTICLE HELPFUL?

Not Helpful