Regex for fixed length string, starting with multiple words -
i'm trying make regex (js flavor) matches string 17 alphanumeric characters in length , must start either "ab, "de" or "gh". after these 3 possibilities, alphanumeric character accepted.
match:
ab163829f13246915 det639601ba167860 ghf1973771a002957
don't match
xyz63829f13246915 aaa639601ba167860 bbc1973771a002957
so far have regex i'm testing on http://regexpal.com/
^(ab|)[a-za-z0-9]{17}$
not sure why pipe character required match first example, or why fails when add "de" after pipe.
anyone?
use this:
^(ab|de|gh)[a-za-z0-9]{15}$
the first 2 characters take two, need 15 more alphanumeric characters after that.
Comments
Post a Comment