0

My code:

<input ng-required="{{ ixarisCurrOpts[0].selected }}" 
      ng-pattern="[0R]{2}[a-zA-Z0-9_-]{23}" ng-click="returnFundAccGBP()" 
      ng-focus="fFundAccGBP=true" 
      ng-change="returnFundAccGBP()" ng-blur="fFundAccGBP=false" 
      ng-model="fundAccGBP" id="fundAccGBP" name="fundAccGBP" type="text" 
      placeholder="{{ fundAccRegexPrefix }}ACO_EpAn03f8X-DyWAc0n3L"
      class="form-control input-md" maxlength="25" ng-class="fFundAccGBPDef">

I keep getting this error in the google chrome debugger:

Error:

[$parse:syntax] Syntax Error: Token 'R' is unexpected, expecting []] at column 3 of the expression [[0R]{2}[a-zA-Z0-9_-]{23}] starting at [R]{2}[a-zA-Z0-9_-]{23}].

1
  • change your regex to: /^[0R]{2}[a-zA-Z0-9_-]{23}/ Commented May 16, 2017 at 15:00

2 Answers 2

0

Adding to what's already been said: you should use "^" and "$" in the beginning and the end of the pattern, respectively:

"/^[0R]{2}[a-zA-Z0-9_-]{23}$^/"

This way, you assert that the pattern starts working from the beginning to the very end of the string.

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

Comments

0

Your ng-pattern syntax is incorrect. It has to be inside fwd. slash /.../.

Change it to ng-pattern="/^[0R]{2}[a-zA-Z0-9_-]{23}$/". It will work.

pattern regex updated too.

Comments

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.