LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What's wrong with this regular expression?

I am passing a path (converted to string) to search and replace string function (with regular expression checked in the right click menu of the function). I am passing this regular expression  to search string input "\.(vit¦vi)" (without the quotes). I am trying to find any vi or vit files and do processing on this basis in the case structure. But  only the true case of the case structure is working. I'm attaching the code's graphic. Please advise.
Thanks!
0 Kudos
Message 1 of 6
(3,078 Views)

I have made a testvi with the Serach and Replace primitive. I also set to regluar expression. It is working as expected at least in LV8.5. xy.vi will give 2 as offset after replace and xy.v will give -1.

You said you will always get -1 I suggest to check the string if there is really the extention. Another reason is that you are not receiving the VI name but something else.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 2 of 6
(3,062 Views)
An easier solution would be to use the Get File Extension VI:






Message Edited by smercurio_fc on 03-07-2008 09:04 AM
0 Kudos
Message 3 of 6
(3,026 Views)
Thanks smercurio… for the wisdom!
(Why can't I see simple solutions when they exist right under my eye? Is our brain programmed to overlook simplicity as less of an intelligent option?).
Thanks a lot!
0 Kudos
Message 4 of 6
(2,989 Views)


rashid19672008 wrote:
 I am passing this regular expression  to search string input "\.(vit¦vi)" (without the quotes).



This may help with the original question, and in other RE's you write...
 
On my keyboard, there are two very similar characters, | and ¦
 
The | is the one that works as alternation in an RE, not ¦
 
Also it may be handy to set a T constant to the "ingore case" input if there could be upper case letters in the filename (The get file extension solution removes this problem as it uses a "to lower case")
 
Rod.
0 Kudos
Message 5 of 6
(2,972 Views)

Hi Rod,

I have seen this difference in the characters in the image. I thought this is a matter of fonts used because on my german keyboard I only have this one: |. The other one is missing.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 6 of 6
(2,966 Views)