lundi 14 janvier 2019

regex topleveldomain with/without numbers

I'm trying to figure out how to use the regex if=then|else statement.
This code:

(?(?=(.*)[.][a-zA-Z]{2}$)(.*)[.](.*)[.][a-zA-Z]{2}$|(.*)[.](.*)[.][a-zA-Z0-9]{2,}$)

should ask for the last 2 characters after the dot.

If there is no number in it, use the "then" regex, only letters are allowed.
If there are more than 2 letters after the dot all letters and numbers should be allowed.
Shouldn't this code do this or do I miss smth?
Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire