polohy
polohy

Reputation: 287

Use czech chars in regular expression

I need to use regular expression in my webapp, which allows czech characters (ěščřžýáíéóúůďťňĎŇŤŠČŘŽÝÁÍÉÚŮ). Current I have

[a-zA-Z]*\w{1,20}

but this doesn't allow to input them. Thanks

Upvotes: 2

Views: 5628

Answers (4)

Kara
Kara

Reputation: 1

[Á-žA-z] should capture most of the characters

Upvotes: 0

L.B
L.B

Reputation: 116108

var words = Regex.Matches(inputstr, @"[ěščřžýáíéóúůďťňĎŇŤŠČŘŽÝÁÍÉÚŮĚÓa-zA-Z]{1,20}")
                .Cast<Match>()
                .ToArray();

Upvotes: 6

ondrajuda
ondrajuda

Reputation: 21

Based on this documentation you can use \p{L} to match any letter.

https://javascript.info/regexp-unicode

Upvotes: 2

Balazs Tihanyi
Balazs Tihanyi

Reputation: 6719

Alternative solution (works only for .NET):

[\p{Ll}\p{Lu}]{1,20}

Upvotes: 3

Related Questions