I need a regex for checking if a Xbox Live Gamertag is valid:
Aa-Zz, 0-9, single spaces, can't start with a number (min 1, max 15)
I can't get it to not allow double spaces..
Any idea?
can a single space be a valid input? From your rules, as they are stated, it can.
if yes, then try this. Your regex engine must support look-arounds:
^(?!.*\x20{2})[A-Za-z\x20][A-Za-z\d\x20]{0,14}$
Thanks!
It's for PHP. I don't know if it supports it, but I'll try it.
It does support it:
if (preg_match('/^(?!.* {2}|^\d)[A-Z\d ]{1,15}$/i',$sourcestring)) {
// do something
} else {
// do something else
}