Although regular expression syntax is 99% interchangeable between languages, keep this in mind:
"."
) does not match a line feed (newline, line break, "\n"
) in any language./foo/i
makes the pattern case-insensitive in many languages. Note however that some of these modifiers may not exist or mean entirely different things in different languages.Here is how to make the dot match line feeds in various languages:
You can make the dot match line feeds by using the /m
modifier. If you come from other languages, do not use the /s
modifier in Ruby. It
changes the RegExp to interpret text as Shift JIS encoded
Show archive.org snapshot
which you probably don't want.
There is no modifier to make the dot match line feeds. You need to write [\s\S]
or (.|\s)
to match any character including line feeds, carriage returns, etc.
While there is a /m
modifier in Javascript, it only changes the meaning of ^
and $
.
You can make the dot match line feeds by using the /s
modifier. Note that there is also /m
, which does something very different in Perl than in Ruby.