Hi,
What is the regex for a alpha numeric word, at least 6 characters long (but at most 50).
Hi,
What is the regex for a alpha numeric word, at least 6 characters long (but at most 50).
With PCRE regex you could do this:
/[a-zA-Z0-9]{6,50}/
It would be very hard to do in regex without the min/max quantifiers so hopefully your language supports them.
/[a-zA-Z0-9]{6,50}/
You can use word boundaries at the beginning/end (\b) if you want to actually match a word within text.
/\b[a-zA-Z0-9]{6,50}\b/
\b\w{6,50}\b
\w
is any 'word' character - depending on regex flavour it might be just [a-z0-9_] or it might include others (e.g. accented chars/etc).
{6,50}
means between 6 and 50 (inclusive)
\b
means word boundary (ensuring the word does not exceed the 50 at either end).
After re-reading, it appears that what you want do is ensure the entire text matches? If so...
^\w{6,50}$