Ng-pattern for alphanumeric and all special characters

On input, I need to allow alphanumeric and all special character characters. I am using the following template. Unfortunately it doesn't work.

ng-pattern="/^[ A-Za-z0-9_@./#$=!%^)(]:*;?/\,}{'|<>[&+-]*$/"

      

+3


source to share


1 answer


You missed to avoid all characters that need to be processed with \

. The following might work:

ng-pattern="/^[A-Za-z0-9_@.#$=!%^)(\]:\*;\?\/\,}{'\|<>\[&\+-]*$/"

      

Note that this can be simplified:



ng-pattern="/^[A-z\d_@.#$=!%^)(\]:\*;\?\/\,}{'\|<>\[&\+-]*$/"

      

Check it out on regex101

+2


source







All Articles