0

I have simple regex ^[a-zA-Z0-9,. ]*$

I test it in .NET like this:

Regex.IsMatch(description, @"^[a-zA-Z0-9,. ]*$")

I do not understand why when there is "\n" EOL char on the end of the string then why this string matches. Or - how should the correct regex that is ignoring \n on the end would look like?

Examples:

"abc .123," - matches

"abc .123,\n" - matches, but WHY?

"abc\n .123," - does not match

But if I test this regex e.g. on http://regexstorm.net/tester the same string with \n on the end DOES NOT match (which I hope is correct).

Thank You all.

0 Answers0