1

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 *

1 Answer 1

1

Javascript won't support \A (start), \z (end) anchors. So i suggest you to replace them with ^ and $

^(.*)[^\t\r\n]$
Sign up to request clarification or add additional context in comments.

5 Comments

unfortunately I cannot use ^ and $ as my regex works also on multiple lines by checking for unwanted "newline" characters
so you want to match the lines which have no newline chars?
I want to match lines without newlines, tab and carriage return. I tested you suggestions but didn't work.
I finally solved it by using ^ and $ as start of string and end of string delimiters. So the final regex that works for Javascript is: ^(.*)[^\t\r\n]$
@OuterSpace thats what i said at first . See stackoverflow.com/posts/28109026/revisions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.