Before asking I looked for several references, but I still do not understand much and managed to reach only to a certain extent.
My goal is to validate that a specific string
has 10 characters, the first two letters being uppercase, and the other 8 character numbers.
The first two letters should be obligatorily AD, AG, or EX. They can not be AE or EG for example.
For this I have the following Regex
/^[A(D|G)|EX]{2}[0-9]{8}$/gm
. But it does not fulfill the second rule. It allows the letters AGDEX to be mixed, not in the specific order desired.
I'm using RegExr to validate my regex
with the following values:
EX09551115
AD09551115
AG09551115
EA09551115
EG09551115
AE09551115
AX09551115
DG09551115
GD09551115
XE09551115
GA09551115
DA09551115
XD09551115
XG09551115
GX09551115
DX09551115
Only values in bold should be valid values.
What I desire is to know how I do to satisfy the second condition. You do not have to leave a regex
ready, just showing me the way will be a great help.
References are also welcome.