0

It seems RegexOptions.CultureInvariant does not work.

var match = Regex.Match("välue", @"^[a-zA-Z0-9_-]+$", RegexOptions.CultureInvariant);
//match.Success is flase!!!

I'm trying to match all alphanumeric strings in different cultures.

Mhd
  • 2,778
  • 5
  • 22
  • 59
  • 1
    Possible duplicate of [Allow only letters and "special" letters (éèà etc.) through a regex](https://stackoverflow.com/questions/15131632/allow-only-letters-and-special-letters-%c3%a9%c3%a8%c3%a0-etc-through-a-regex) – Xiaoy312 May 14 '18 at 19:42
  • 2
    Accented letters are not within the `[a-z]` or `[A-Z]` range. – Xiaoy312 May 14 '18 at 19:43

1 Answers1

0

Maybe this will helps someone.

var match = System.Text.RegularExpressions.Regex.Match("välueÇöıÜ_-", @"^[\p{L}0-9_-]+$", System.Text.RegularExpressions.RegexOptions.CultureInvariant);

\p{L} matches any letters.

You may also look.

Muzaffer Galata
  • 580
  • 1
  • 9
  • 22