tags:

views:

68

answers:

1

I have written a regular expression for text parser as following:

^\s*(?<Count>[0-9]+)\s*[x|X]\s*(?<Currency>[^\d\sN]?)(?<ParVal>\d+)(?<Type>[^Nn]?)\s.*$

to capture the pattern such as:

....
1 x 1p
1 x 3p 
....

It works well, however I don't know how to detect whenever 1 x 1p pattern is above/bellow the STOP line in regular expression (I'm just a regx newbie :-( )

....
1 x 1p    <= here
1 x 3p
STOP
1 x 1p     <= and here
....

Hope you can understood my problem.

+2  A: 

That regex is being applied to one line at a time, so when you're looping over the lines, just check first if the line is "STOP", and if it is, break out of your loop. The check can't be done as part of the regex.

Chad Birch