The following returns true
Regex.IsMatch(\"FooBar\\n\", \"^([A-Z]([a-z][A-Z]?)+)$\");
so does
Regex.IsMatch(\"FooBar\\n\",
From wikipedia:
$ Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line.
So you are asking whether there is a capital letter after the start of the beginning of the string, followed by any number of times (zero or one letter), followed by the end of the string, or the position just before the newline.
That all seems true.
And yes, there seems to be some mismatch between different documentation sources about what is regarded as newline and how $ works or should work exactly. It always brings to mind the wisdom:
Sometimes a man has a problem and he figures he will use a regex to solve it.
Now the man has two problems.
In .NET regex, the $ anchor (as in PCRE, Python, PCRE, Perl, but not JavaScript) matches the end of line, or the position before the final newline ("\n") character in the string.
See this documentation:
$The match must occur at the end of the string or line, or before\nat the end of the string or line. For more information, see End of String or Line.
No modifier can redefine this in .NET regex (in PCRE, you can use D PCRE_DOLLAR_ENDONLY modifier).
You must be looking for \z anchor: it matches only at the very end of the string:
\zThe match must occur at the end of the string only. For more information, see End of String Only.
A short test in C#:
Console.WriteLine(Regex.IsMatch("FooBar\n", @"^[A-Z]([a-z][A-Z]?)+$")); // => True
Console.WriteLine(Regex.IsMatch("FooBar\n", @"^[A-Z]([a-z][A-Z]?)+\z")); // => False