LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression replace

I'm wondering about an inconsistency between

"search and replace regular pattern.vi" and
"search regular expression.vi"

found in string functions palette.

 

Here is my data:

input : ein test "text"

search: (["*$])(\w+)\1

replace: foo

 

In the second vi, last parameter is not available but thats not important, here.

 

Now my question:

"search regular expression.vi" finds "text" and sets the output before match to "ein test" as well as the output
after match to nothing. This is also the expected result.

Instead "search and replace regular pattern.vi"  finds no match (returns -1 on offset after match) and therefore also

returns the whole input string as the result string.

This is mentioned inconsistency, because the regex should of course be valid for both string palette vi's.

Is there a workaround or did i understand something wrong?

 

Thank you!

regex.PNG

 

0 Kudos
Message 1 of 5
(3,219 Views)

Labuser16383, check this thread http://forums.ni.com/t5/LabVIEW/quot-Match-Regular-Expression-quot-and-quot-Match-Pattern-quot/td-p/... .

Briefly - Search and replace regular pattern.vi has limited set of regular expressions, which it can use. That's why these two VIs behave in different way.

0 Kudos
Message 2 of 5
(3,199 Views)

Ok, i understand. Thank you.

Now the question is, what function should be used instead?

"Search and replace string.vi" with regex enabled?

 

0 Kudos
Message 3 of 5
(3,183 Views)

It's difficult for me to give an answer on it - b/c I didn't use Search and replace string.VI with regex enabled - but, you can just try, and see, whether it works...

0 Kudos
Message 4 of 5
(3,130 Views)

Search works. Replace works only, if no backreferences are beeing used (eg $1, $2 ...).

Are there some others who know this kind of problems?

 

0 Kudos
Message 5 of 5
(3,099 Views)