in reply to Re: Re: regular expression
in thread Matching lines in a file that end in numbers (was: regular expression)
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.x = ReallyLongFunctionNameNumber1() + 130 + AnotherCrazyLongFunctionNameThatIsOnItsOwnLine();
|
|---|