ziedTn
ziedTn

Reputation: 262

ng-pattern for angularjs wrong behaviour

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

Upvotes: 0

Views: 620

Answers (1)

Wilt
Wilt

Reputation: 44345

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...

Upvotes: 1

Related Questions