Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: One liner

by AnomalousMonk (Archbishop)
on Jun 02, 2009 at 19:00 UTC ( [id://767732]=note: print w/replies, xml ) Need Help??


in reply to One liner

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):
'   Total SE ON    ----    1234   '

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://767732]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found