OuterSpace
OuterSpace

Reputation: 425

Regex issue with AngularJS ng-pattern

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

Answers (1)

Avinash Raj
Avinash Raj

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

Related Questions