First of all I'm using ASP.NET MVC5 for my business app and I need some help for regex data annotations. All regex-expression should work client & server-side.
1. Regex for special chars
I'm looking for a short regex to allow special chars for typical Lastnames in Europe, including umlaut letters ??ü??ü?...
, accented letter like èèéàù...
and also caron letters ǎǎěě...
I found some recommendations to use w
this topic or p{L}
.
As explained I'm using data annotations => RegularExpression which are also used for the model-fields on the client-side (I'm using Devextreme which uses the data annotations for client-side checks).
The above w
will only work for the server-side check, but not at the client for javascript. Is there a way to check on client and server without writing all the single letters/chars inside the RegularExpression?
2. Regex for common chars used in phrases
Are there any predefined "shortcuts" (like wsd
) to allow common chars used in phrases (e.g. punctuation mark's, hashtag, @) like #+*~$%&/()[]@,.;:_-='"
inside a multiline text (e.g. comment / notes section for the users)?
=> Alternative if 1. and/or 2. not possible?
If 1. and/or 2. are not possible, I assume the best way would be to write a custom data annotation? There would be around 50 model-fields for case 2. and I don't want to write the regex 50 times (If I have to change something, I would have to change it 50 times).
question from:
https://stackoverflow.com/questions/65846407/asp-net-mvc-regex-for-sepcial-characters-client-server-regex-for-common-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…