Given the UnicodeString, s, containing "Mary\n" and a RegexMatcher, m, compiled with the pattern "Mary$", if I do:
m->reset(s);
bool b = m->find() != 0;
then b gets set to true. Why? The pattern says that the 'y' of "Mary" should be at the end of the string. In this case, it’s not the end of the string — the '\n' is. It should be set to true only if the UREGEX_MULTILINE option were set. Right?
This is using the C++ ICU version 4.8.1.
This is normal behavior:
$matches at the end of the string or line (depending on the(?m)orMULTILINEflag) before any trailing newline. See this tutorial on anchors (scroll down about halfways to “Strings ending with a line break”).Use
\zinstead – that only matches at the very end of the string.