\A # beginning of string
\n # newline
\Z # end of string
And by the way … “\n” and /\n/ may not be the same, depending on what
the regexp wants to do with the backslash! you could try escaping it.
What do you want to match?
maybe:
/A # beginning of string
.* # any characters
\n # newline
.* # any characters
/Z # end of string
Looks like I’ve solved my own problem the \Z in ruby doesn’t have the
same semantics as it does in other languages. There is a \z which is
what I wanted so as expected:
/\A\n\z/m.match(“\n\n”) => nil
\z end of a string
\Z end of a string, or before newline at the end
So, \Z allows an extra \n at the end of the string.
Looks like I’ve solved my own problem the \Z in ruby doesn’t have the
same semantics as it does in other languages. There is a \z which is
what I wanted so as expected: