I have a list of words, one to each line, and each word has a single character at the end that denotes its part of speech. Therefore, I'm trying to write a regular expression that will match a single character at the end of line, so I can parse through this data.
I can't just use something like [N$] because it will just match the first 'N' from the end of the line, not just lines that end in N. So I want something that will match a single character at the end of a line.
So if my data contained something like: BounceN BouncerV
I would want the regular expression to match 'N' at the end of a line to match just "BounceN" and not "BouncerV".
Thanks for you time, and thanks in advance to anyone that can help.
Burkhard Hassel
Ranch Hand
Joined: Aug 25, 2006
Posts: 1274
posted
0
Hi cowboys,
Ron Landreth posted November 03, 2006 10:57 PM
I would want the regular expression to match 'N' at the end of a line to match just "BounceN" and not "BouncerV".
You will need the greedy quantifier .* followed by an N$.
.*N$
means any number of any characters (including zero) followed by an N at the end of the line, and process whole string first.
It will find in the sequence "BouNcerN" only the whole bouncer, not the "BouN" and not the "cerN".