Regex to match any character including new lines
If you don't want add the /s
regex modifier (perhaps you still want .
to retain its original meaning elsewhere in the regex), you may also use a character class. One possibility:
[\S\s]
a character which is not a space or is a space. In other words, any character.
You can also change modifiers locally in a small part of the regex, like so:
(?s:.)
Add the s
modifier to your regex to cause .
to match newlines:
$string =~ /(START)(.+?)(END)/s;