in reply to Multiple Search and Replaces on one file

output:
syntax error at dumpop.pl line 23, near ") {" syntax error at dumpop.pl line 26, near "}" dumpop.pl had compilation errors.
so...

and then there's your match

m/(.+.WARNING)(.+)/g
which has me scratching my head in bewilderment. Could this be what you meant?
m/(?:.+)(?=WARNING)WARNING\s(.+)

(in which case $1 is the capture.)

Replies are listed 'Best First'.
Re^2: Multiple Search and Replaces on one file
by monger (Friar) on Jun 15, 2005 at 17:18 UTC
    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
      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
Re^2: Multiple Search and Replaces on one file
by kaif (Friar) on Jun 15, 2005 at 16:13 UTC

    m/(?:.+)(?=WARNING)WARNING\s(.+)

    Out of curiosity, why the double WARNING?

A reply falls below the community's threshold of quality. You may see it by logging in.