solarisuser Posted June 21, 2007 Share Posted June 21, 2007 Hi All, Is it possible to combine these two regexs I use? I'm not well versed in regex.... First One: /^[a-zA-Z0-9 -]+$/ Second One: /^.{3,21}$/ Essentially, allow "a-zA-z0-9, spaces, and dashes", and it must be between 3 and 21 characters in length. Quote Link to comment Share on other sites More sharing options...
rea|and Posted June 21, 2007 Share Posted June 21, 2007 You could replace + with {3,21} /^[a-zA-Z0-9 -]{3,21}$/ or use a lookahead assertion like /^(?=.{3,21}$)[a-zA-Z0-9\x20-]+$/ In this case first it checks the number of chars and afterward it checks the characters. Quote Link to comment Share on other sites More sharing options...
solarisuser Posted June 21, 2007 Author Share Posted June 21, 2007 thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.