
July 16th, 2009, 07:58 AM
|
|
Registered User
|
|
Join Date: Dec 2007
Posts: 29
  
Time spent in forums: 9 h 26 m 42 sec
Reputation Power: 0
|
|
|
Underscore or hiphen should come once but not at boundaries
Hi
I am in a fix
i need to write a regular expression for this situation...
1) a-z and 0-9 allowed with _ or -
2) _ or - should not come more than one; and should not be at the boundaries and both cannot come together
3) range : 3 to 16
Examples::
1) te-st = true
2) test = true
2) te-_st = false
3) -test or test_ = false
This is what i came up with so far
Code:
^([a-z0-9]+(-|_)?[a-z0-9]+){3,16}$
Thank you for any help
|