In a regular expression, in multiline mode, ^
and $
stand for the start and end of line. How can I match the end of the whole string?
In the string
Hello\nMary\nSmith\nHello\nJim\nDow
the expression
/^Hello(?:$).+?(?:$).+?$/ms
matches Hello\nMary\Smith
.
I wonder whether there is a metacharacter (like \ENDSTRING
) that matches the end of the whole string, not just line, such that
/^Hello(?:$).+?(?:$).+?\ENDSTRING/ms
would match Hello\nJim\nDow
. Similarly, a metacharacter to match the start of the whole string, not a line.