3.10. Matching a Newline with a Dot
Ordinarily a dot matches any character except a newline. When the m (multiline) modifier is used, a newline will be matched by a dot. The same is true when the Regexp::MULTILINE option is used in creating a regex:
str = "Rubies are red\nAnd violets are blue.\n" pat1 = /red./ pat2 = /red./m str =~ pat1 # nil str =~ pat2 # 11
This multiline mode has no effect on where anchors match (such as ^, $, \A, and \Z); they match in the same places. All that is affected is whether a dot matches a newline.