in reply to Re: Multiple Search and Replaces on one file
in thread Multiple Search and Replaces on one file

and then there's your match
m/(.+.WARNING)(.+)/g

I arrived at this via trial and error. First, I tried \w, but there are spaces. I then went to ".", but had to add the greedy +. So, I'm up to
m/(.+WARNING)...

It still didn't match, so I added the second "." to get what you see. The parens are there to grab only what's after WARNING, regardless of what it is, hence (.+).

monger

Monger +++++++++++++++++++++++++ Munging Perl on the side

Replies are listed 'Best First'.
Re^3: Multiple Search and Replaces on one file
by ww (Archbishop) on Jun 15, 2005 at 17:40 UTC
    monger:

    You said you don't want the first set of date/time info, nor the "WARNING" ... so why capture them at all? Use non_captureing parens,     (:...) for that which you are using merely as a marker for the string you want.

    Please read the two items surrounding kaif's question... (Aargh; seem to have sent reply to kaif's to bitbucket, so repeating below) and more particularly (or, at least, even more diligently) the suggestions from holli, et al.

    Update:

     (?=WARNING) is a lookahead (aka lookaround), which

    • matches at the POSITION or "location" before "WARNING" (ie, uses "WARNING" as a marker to delimit the prior part(s) of the regex; you can think of this as a way to limit greediness, tho that's very sloppy language) but...
    • does not capture "WARNING"!
    so...

    the second "WARNING" in the regex matches the word itself which therefore gets included (along with the trailing \s, space) in the NON_capture,  (?:...)

    HTH