Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

.net - ASP.NET MVC - Regex for sepcial characters (client & server), Regex for common chars used in phrases

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...