Reputation: 425
I'm facing an issue with a regex using Angular JS ng-pattern. I wrote the following regex for input validation that rejects all input containing newlines, tabs and carriage return:
\A(.*)[^\t\r\n]\z
I tested using Rubular and it works. But then when I put in the ng-pattern of my .aspx the same expression with the bounds /myregex/ (that is: /\A(.*)[^\t\r\n]\z/ ) and, obviously I specify the trigger condition "...$error.pattern", it doesn't work, namely it always considers the input as wrong. Edit: in my regex after "A(." there is also a *
Upvotes: 1
Views: 675
Reputation: 174826
Javascript won't support \A
(start), \z
(end) anchors. So i suggest you to replace them with ^
and $
^(.*)[^\t\r\n]$
Upvotes: 1