C # text mask

I need to check for a specific property on one of my classes. When I set the property, the class has to validate the input and if it is invalid, set the object to an invalid state.

Question. The property value must be in a specific mask / format, for example. && & & - && & & - && & &. I cannot use regular expressions. Can text be checked for mask value?

thank

+1


source to share


3 answers


Regular expressions are often overused, but this is a pretty good example of when a regex is perfect ... so: why can't you use them here?



+2


source


Is it possible to check text against mask value?

It is of course possible that you can write a function to take a string and a mask and check against one another.



So, I don't understand what you are asking about, asking if there are functions in the standard .Net libraries? Or ask for an implementation of the mask check function? Or something else?

If you are looking for something in the library to help, the MaskedTextProvider will probably do it, although it will overdo it.

0


source


Without regexp, you have to write your own validation code that validates the mask.

0


source







All Articles