I'm trying to create a regular expression to match on a specific given number pattern.
The patterns are:
123456
1234XX
1234*
Not allowed are:
A combinations like: 1234*X
or 1234X*
Or a multiple *
: 1234**
I already tried this expression:
/^[\\+\\#\\*0-9]{0,25}[X]*$/
But here I got the multiple *
and 1234*X
as valid expressions.
Does anyone have an idea of a proper soultion or a way to a solution?
Edit: Ok, I think I should clearify the rules.
The regex should match any given number:
012345
+12345
#1234525
But also match for strings with a X
in it.
12345X
12345XX
1234XXXXXX
XXXXXX
The X
s should always stand on the end of the string.
A single *
should only be allowed at the end of the string.
1234*
1234556*
1*
Multiple *
aren't allowed. Only one *
at the end of the string.
The combination of X
and *
are not allowed. 1234X*
or 12345*X
are not allowed.
Length restriction: 0 to 25 characters.