in reply to Re: Replace character not inside comments
in thread Replace character not inside comments

how would i make this work if the comment spanned more than 1 line?
  • Comment on Re: Re: Replace character not inside comments

Replies are listed 'Best First'.
Re: Re: Re: Replace character not inside comments
by thpfft (Chaplain) on Sep 04, 2002 at 20:11 UTC

    just adding an s modifier to each regex ought to do it: it'll then treat the whole thing as if it were one line (or, strictly, it'll treat line-endings as just another character), as the early parts of perlre will explain. I should have put that in, but your example was just one line so I didn't bother:

    $test =~ s/(\\\*.*?\*\\)/ push @comments, $1; '%%comment%%' /egs; $test =~ s/\\//gs; $test =~ s/%%comment%%/ shift @comments /egs;