c# - Ways to share regex across DataAnnotations /Attributes -


I get some recognition on my ASP.NET, with a view to play with System.ComponentModel.DataAnnotations namespace I am here. MVC application

I have already raised an issue with regular expansion annotation.

Because these are annotation attributes, they require steady expression.

OK, I can use a square filled with Regex string constant.

With that problem, I do not want to pollute my regex with the required escape characters for the C # parser. My choice is to store regex in the resource file.

The problem is that I can not use those string resources in my data annotation, because they are not static!

Is there a solution

If not, then it takes a significant limitation to use the attributes for verification.

You only need one escape code in C # (double quote) ... If you use the word string literally:

  @ "like \ this \ note \ slash does not do anything here", only "doubting" is needed, you too Newline can use ";  

I type regex with always @ "..." string - avoids multiple headaches.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -