I want to make an Angularjs regex validation that allow all alphabets, numbers, space and following special characters ! ' " & - ( )
1 Answer
You may use
ng-pattern="/^[a-zA-Z0-9\s!'\x22&()-]*$/"
Details
^- start of string[a-zA-Z0-9\s!'\x22&()-]*- 0 or more:a-zA-Z- ASCII letters0-9- ASCII digits\s- whitespaces!'\x22&()--!,',"(\x22matches"),&,(,)or-(the hyphen must be at the end/start of the character class or escaped to denote a literal-)
$- end of string.
2 Comments
cst1992
This regex doesn't seem to be complete. There are symbols missing, such as
@.Wiktor Stribiżew
@cst1992: See the requirement: all alphabets, numbers, space and following special characters
! ' " & - ( ). No mentioning of @.
ng-pattern="/^[a-zA-Z0-9\s!'\x22&()-]*$/"