0

I'm using this Regex ^[a-zA-Z0-9]{2,20}$ to allow the following rules: - Letters a-z - Letters A-Z - Numbers 0-9 - Input length must be at least 2 characters and maximum 20 characters.

I also want to allow apostrophe only at the end of words ending with s.

Thanks,

jkigel
  • 1,592
  • 6
  • 28
  • 49

1 Answers1

2
^([a-zA-Z0-9]{2,20}|[a-zA-Z0-9]{2,18}'s)$

So: either your original regex, or your original regex (reduced to maximum 18 characters, you might want to change the minimum as well) ending in "'s".

porges
  • 30,133
  • 4
  • 83
  • 114
  • Thank you for your answer but I receive false for the input user's name for example when using it in PHP - return preg_match("/^([a-zA-Z0-9]{2,20}|[a-zA-Z0-9]{2,18}'s)$/", $this->input); – jkigel Aug 01 '11 at 08:08