3

In input, I need to allow alphanumeric and all special symbol character. I am using the following pattern. Unfortunatelly, it is not working.

ng-pattern="/^[ A-Za-z0-9_@./#$=!%^)(]:*;?/\,}{'|<>[&+-]*$/"
Mistalis
  • 17,793
  • 13
  • 73
  • 97
Nithin
  • 483
  • 5
  • 11

1 Answers1

4

You missed to escape all the characters that should be excaped with \. The following may work:

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

Note that it could be simplified to:

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

Test it on regex101

Mistalis
  • 17,793
  • 13
  • 73
  • 97