in reply to Re: Re: regular expression
in thread Matching lines in a file that end in numbers (was: regular expression)

What I would suggest is:     print "$1\n" if (/^(.*?)\s*\d+$/); This will have the effect of removing the trailing space from the line.

I'm not sure if this will be an issue for your application or not, but your program might get a bit carried away if you (or someone else) spaced out some of your expressions, such as:
x = ReallyLongFunctionNameNumber1() + 130 + AnotherCrazyLongFunctionNameThatIsOnItsOwnLine();
I would presume that you don't want the program to pick up on that line, in which case, a slightly safer version might be to put a semi-colon in your regexp, like so:     print "$1\n" if (/^(.*?;)\s*\d+$/); Or to demand a specific quantity of numbers, such as 5:     print "$1\n" if (/^(.*?)\s*\d{5}$/); Although, to be truly "safe", you would want to change the format of your numerical markup system slightly, such as turning it into a comment, like:     int i; // #20005 Where '// #20005' is not very likely to show up anywhere else in your code.

Though, of course, this will depend on the context of your application, and it might be way over-kill.