LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW regex for multi-line tags

Solved!
Go to solution

Hi,

I have the following string:

<Type1>
<Name>Name1</Name>
<Val>Val1</Val>
</Type1>
<Type2>
<Name>Name2</Name>
<Val>Val2</Val>
</Type2>
<Type3>
<Name>Name3</Name>
<Val>Val3</Val>
</Type3>

 

Iam trying to use regex to get the strings between Type1/2/3.

I am able to do this using the following regex:

<Type3>(.*?)<\/Type3>|<Type1>(.*?)<\/Type1>|<Type2>(.*?)<\/Type2>

 

on regex101.com with PCRE, but not able to replicate the same in LabVIEW. I get the entire string as before match.

What am I doing wrong here?

 

Screenshot from regex101.com

johndoe858_0-1588319234179.png

 

 

0 Kudos
Message 1 of 3
(2,408 Views)
Solution
Accepted by johndoe858

Change the expression to:

"(?s)<Type3>(.*?)</Type3>|<Type1>(.*?)</Type1>|<Type2>(.*?)</Type2>"

 

The "(?s)" tells the reg.ex. to match \r and \n as any character (".").

 

This is not the same as setting "multiline?" to true. The help informs us that this effects the anchors, "$" and "^". This is actually a "(?m)".

 

See https://www.regular-expressions.info/modifiers.html for the logic behind "(?s)" amd "(?m)".

Message 2 of 3
(2,386 Views)

Thanks a lot for the prompt response.

 

 

0 Kudos
Message 3 of 3
(2,351 Views)