in reply to Re: Match pattern per line and after another one as multiline in single file opening
in thread Match pattern per line and after another one as multiline in single file opening

Not to be a broken record, but Re^2: Match pattern per line and after another one as multiline in single file opening:
I read the description as he needs the [^}] to match through newlines, and so there needs to be a slurp before the regex. But your point about lack of test real data is very appropriate.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

  • Comment on Re^2: Match pattern per line and after another one as multiline in single file opening
  • Download Code

Replies are listed 'Best First'.
Re^3: Match pattern per line and after another one as multiline in single file opening
by BillKSmith (Monsignor) on Feb 15, 2017 at 02:42 UTC
    In that view, I would use only the OP's second program. All comments can be removed with a single substitution: $data =~ s/^\s*#.*?\n//msg;
    Bill
      I agree, though his regex also stripped empty lines, so maybe $data =~ s/^(?:\s*#.*)?\n//mg;

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      I know it is almost two years after, but I just want to thank you all for your suggestions. I wasn't visiting this site often in the meantime, as I have spent time on project with a strong preference for python. I think my Perl code wasn't used at the end. I remember that the original file was dhcp configuration file at RHEL5, but I don't remember what data exactly I was trying to extract at the time. Once again thanks!