05-01-2020 02:47 AM
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
Solved! Go to Solution.
05-01-2020 03:36 AM - edited 05-01-2020 03:39 AM
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)".
05-01-2020 10:50 AM
Thanks a lot for the prompt response.