Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mask input by regular expressions? either 1112223333 or 1112223333444

This is within a xaml file.

I need to mask a box's input with a regular expression.

I need it to contain either 10 numbers or 13 numbers (in sequence, with no symbols)

I have :

<... ValidationRegEx="\d{13}" />

which works fine, but when i want to add a mask of ten in , it breaks :

<... ValidationRegEx="\d{13} | \d{10}" />

Any ideas?

like image 800
jordan Avatar asked Oct 16 '12 21:10

jordan


1 Answers

I thin the spaces should be removed, like this:

ValidationRegEx = "\d{13}|\d{10}"

Otherwise, space characters become part of the string that you match (i.e. 13 digits followed by a space, or a space followed by ten digits).

You could also try simplifying the expression like this:

ValidationRegEx = "\d{10}\d{3}?"

(required ten plus three optional digits).

like image 116
Sergey Kalinichenko Avatar answered Nov 04 '22 23:11

Sergey Kalinichenko