in reply to Really basic regex question!

Your  $code string seems to have newlines in it, and by default,  . (dot) (update: in the  .*? regex expression) does not match newlines. Try using the  /s (dot matches all) regex modifier on your substitution.

Update: Please see Modifiers;   s/// in Regexp Quote-Like Operators.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Really basic regex question!
by ultranerds (Hermit) on Mar 24, 2016 at 06:25 UTC
    Ah man - now I feel stupid! That worked perfectly, thanks! :)