in reply to Chomping most of a _long_ text string

Why not just
s/^.+_{70}//s

?


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Chomping most of a _long_ text string
by RupertSw (Initiate) on May 29, 2005 at 15:58 UTC

    That'll be fine on a long bit of text? I got the impression you were supposed to avoid REs on > ~1kb bits of text.

    In which case, thanks a lot, and I'll shut up and get on with it!

    Rupert
      That should be s/^.+?_{70}//s.
      No, regexes scale well with long strings.


      holli, /regexed monk/
Re^2: Chomping most of a _long_ text string
by RupertSw (Initiate) on May 29, 2005 at 21:22 UTC

    My goodness! Far more replies than I expected!

    Regexes are working wonderfully for me, and I'm pleased to say I got the anti-greediness question mark trick myself (but went to work as a waiter, hence not thanking all the replies earlier)

    What I was actually parsing was a mailbox full of past issues of @Risk, a security list. My code now has a loop doing something like this:

    $$email =~ s/^.+?_{70}\n\n([[:digit:]])/$1/s; while($$email =~ /(\d{2}\.\d+\.\d) CVE: ([^\n]+)\nPlatform: ([^\n]+)\n +Title: ([^\n]+)\nDescription: (.+?)\nRef: (http[^\n]*)/gs) { print "CVE: $2\nPlat: $3\nTitle: $4\nDesc: $5\nURL: $6\n\n"; }

    And, yes, I have yet to tidy up the RE, but it works and is more than fast enough for what I need. Many thanks again

    Rupert