0

i am trying to work with ng-pattern but it throw an error. i want to validate a duration of time with the follwing pattern :

((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)

but i have this error :

Lexer Error: Unexpected next character at columns 76-76 [] in expression [((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?].

it seems that i have problem with back slash but what i know that if i want escaping back slash i have to make two back slash "\". the version of angularjs is 1.2.rc2

1 Answer 1

1

You are actually escaping a white space character. \s is a white space character in a regular expression so by doing \\s you are escaping the white space expression and because of this you are searching for a slash followed by an s: \s

What you might need is an extra closing bracket somewhere there...

Sign up to request clarification or add additional context in comments.

2 Comments

the problem that i have generate the expression from a generator online and i have test it on this site : link and it works fine.
It says in the explanation: "\\ matches the character \ literally s? matches the character s literally (case sensitive)" Because it matches zero or one times you get a match. But you don't want to search at all for a slash and a s

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.