Regex / ng-pattern for accepting certain characters

I use Angular c form validation ng-patternto validate a username using a special charter

ng-pattern="/^[a-z]+@+[a-z]*$/"

My problem is that it is limited to only one type of special charter, which should be placed in the right place.

I would like this to support any of the special characters that we use in the alphabet

+4
source share
2 answers

It is not clear that you are defining a special character, therefore, assuming in your example that it @is a special character.

,, @, ! #, :

ng-pattern="/^[a-z]+[@+!+#][a-z]*$/"

demo: http://plnkr.co/edit/cIjpI9LAJKgs1MvZmBJv?p=preview

+1
/^[a-zA-Z0-9/&quot&quot\\\]\[:;|=,+*?<>]+$/

: , "/\ []:; | =, + *? < >

0

All Articles