Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: One linerby AnomalousMonk (Archbishop) |
on Jun 02, 2009 at 19:00 UTC ( [id://767732]=note: print w/replies, xml ) | Need Help?? |
Update: After going back and looking more closely at all the little red and black plus-signs in the OP (which I probably should have done in the first place), it seems the assertion in the first paragraph of my reply below is not true, so please disregard this reply entirely!
As far as I can tell from the highly folded (not to mention possibly spindled and mutilated) example text given in the OP, the string 'Total SE ON' seems to occur on its own line, but is preceded by a bunch of spaces and followed by bunches of spaces, dashes and spaces before a bunch of digits occurs. (There is a previous line with 'Total SE ON' also, but this seems to be preceded by a '|' (pipe) character and has no digits anywhere after it.)
In other words, the line you want to match looks like this (but with fewer spaces and dashes): If this is the case, I do not see why the original regex would not work with line-by-line processing if only the requirement that 'Total ...' be anchored at the start of the line (the function of the '^' (hat) regex metacharacter), i.e., that it have no characters before it, would be removed. Also, in the context of line-by-line processing, the //s regex modifier, which switches on 'dot-matches-all' regex behavior, is pointless. Further, the regex /Total SE ON\D+(\d+)/ would seem to more clearly express what you are trying to achieve (the \D regex character class represents any character not a digit): it's always best to try to 'say what you mean' with regexen.
In Section
Seekers of Perl Wisdom
|
|