javascript - RegEx: non-consecutive special characters only allowed in the middle -
i using following ng-pattern="/^[a-za-z][a-za-z0-9._](.*[a-za-z0-9])?$/"
the matching string should
- not start special character,
- not end special character, and
- not include consecutive symbols except . (dot) , _ (underscore).
but not working. please, suggestion.
try using word character class start ([\w]
= [a-za-z0-9_]
):
i'm not sure mean consecutive symbols. might help:
/^[a-za-z]([\w.]*[a-za-z0-9])?$/
maybe, have @ javascript regexp reference
Comments
Post a Comment