LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression

Solved!
Go to solution

Hey guys!

 

I'm having troubles coming up with the right reg ex.

 

The string I have to search looks like:

 

LOOPXX

text

text123

123

END LOOP

 

X can be a number vom 1-9.

 

The reg ex should give me all the stuff between the LOOP and END LOOP command.

 

My actual reg ex looks like:

LOOP[1-9]{1,2}[a-z A-Z 0-9 \n \r \s \t]+END LOOP

 

This is matching the string but also givs me the first and last line of the string. And {1,2} is not working properly ... it also matches LOOP1234 and not only LOOP12

 

Thank you in advance!

 

Christoph

0 Kudos
Message 1 of 5
(2,669 Views)

Hi,

 

It always takes me quite a time to get this type of thing correct in a single match, but it is easy to do with two match patterns.

 

Note sure what you want it to do with LOOP1234  my example will give  "LOOP12"   "34    stuff"  "END LOOP" in that example    

 

see attached picy

 

hope this help 

 

dannyt

Danny Thomson AshVire Ltd
Message 2 of 5
(2,650 Views)

Hey.

 

I didn't think about splitting the reg ex.

 

Your version kind of works.

 

Only problem is the match at the beginning:

 

LOOP1, LOOP2 should match and so on. LOOP0, LOOP01 shouldn't match whereas LOOP10, LOOP11 until LOOP99 should match again. Matching one or two characters should work by using {1,2} but it isn't.

 

Reg Ex are really not my favourites 😞

0 Kudos
Message 3 of 5
(2,646 Views)
Solution
Accepted by topic author maehmann

change the first expression to

 

^LOOP[0-9][0-9]?

Message Edited by danny_t on 12-03-2008 04:37 PM
Danny Thomson AshVire Ltd
0 Kudos
Message 4 of 5
(2,642 Views)

Hey!

 

Thanks a lot! 

 

This works now perfectly.

 

Kind Regards

 

Christoph

0 Kudos
Message 5 of 5
(2,604 Views)