I have a query like need to generatre a regex for the String like "12A15" or "12a15".here it has 3 componeners [1-9 max length will be 2][only d or D][1-9 lmax length will be 2] .
I have written Regex to validate a string but still its not able to validate give numbers:
(^[1-9]{1,2}[{d,D}][{4,6,8,10,12,20}]{1,2})+(\s?(\+|\-)\s?)([1-9]{1,2}([{d,D}][{4,6,8,10,12,20}]{1,2}))$
Here, in the regular expression, I am validating a string 12D22 +3d20
. It's telling it is matched, but it should not because 22
is not there in the list. In a valid 5D20+5d12
string, 12
and 20
could be any number from the 4
, 6
, 8
, 12
, 20
list.