6
Before asking I looked for several references, but still do not understand much and I managed to get only to a certain point.
My goal is to validate that a string
specific has 10 characters, the first two letters being uppercase, and the other 8 characters being numbers.
The first two letters must be obligatorily AD, AG or EX. May not be AE or EG for example.
To that end I have the following Regex
/^[A(D|G)|EX]{2}[0-9]{8}$/gm
. But it does not comply with the second rule. It allows the letters AGDEX to be mixed, and not in the specific order desired.
I’m using the 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 bold values shall be valid values.
What I wish is to know how I do to satisfy the second condition. No need to leave a regex
ready, just show me the way will already be of great help.
References will also be welcome.
I had tried it, but for a lack of attention I did not remove the
{2}
that was what ended the condition. Thank you for the reply– Richard Dias
@Richarddias, the problem wasn’t just the
{2}
but the list items, take the regex orginal of your question and see if in the entries||09551115
,((09551115
or))09551115
match the pattern specified in regex ;)– rray
Yes, they hit, that loco. But what I meant, is that I had tried this idea of groups
(AD|AG|EX)
, but had not removed the{2}
– Richard Dias
Some point of the answer is wrong or can be improved?
– rray
If you have any legal references for those who are starting to understand better, it would be nice, but overall cleaned up my problem.
– Richard Dias
@Richarddias, I can add something later, in the tags there is usually a wiki with information and some materials, click on the tag name, then in the info tab. From regex the address is http://answall.com/tags/regex/info Anything calls there
– rray