12-03-2008 09:35 AM
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
Solved! Go to Solution.
12-03-2008 10:16 AM
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
12-03-2008 10:26 AM
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 😞
12-03-2008 10:36 AM - edited 12-03-2008 10:37 AM
change the first expression to
^LOOP[0-9][0-9]?
12-04-2008 01:59 AM
Hey!
Thanks a lot!
This works now perfectly.
Kind Regards
Christoph