LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression.vi doesn't work correctly

I try to parse the output from "Flatten To XML" using "Find Regular Expression" but I get unexpected results.

 

Input: "<LvVariant><Name>myName</Name><Cluster>...</Cluster></LvVariant>"

Regular expression: "<(.+)><Name>(\w+)</Name>(.+)</\1>"

Expected result: match1 = "LvVariant", match2 = "myName", match3 = "<Cluster>...</Cluster>", total match = input, before match = empty, after match = empty.

LabVIEW's result: before match = input, all other output strings are empty.Smiley Frustrated

 

I checked the expression with other programming languages like PHP and Delphi. There it works fine, but not in LabVIEW. I think, there is a bug at the "Find regular expression.vi".

0 Kudos
Message 1 of 2
(2,663 Views)

@ralfc wrote:

I try to parse the output from "Flatten To XML" using "Find Regular Expression" but I get unexpected results.

 

Input: "<LvVariant><Name>myName</Name><Cluster>...</Cluster></LvVariant>"

Regular expression: "<(.+)><Name>(\w+)</Name>(.+)</\1>"

Expected result: match1 = "LvVariant", match2 = "myName", match3 = "<Cluster>...</Cluster>", total match = input, before match = empty, after match = empty.

LabVIEW's result: before match = input, all other output strings are empty.Smiley Frustrated

 

I checked the expression with other programming languages like PHP and Delphi. There it works fine, but not in LabVIEW. I think, there is a bug at the "Find regular expression.vi".


You are not using the Match Regular Expression correctly, try this:

 

Using Match Regex.png

 

You need to expand the bottom of the vi to get the captured groups.

 

Ben64

0 Kudos
Message 2 of 2
(2,653 Views)