Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Unexpected quantifier (JavaScript)

When composing your regular expression search pattern, you created a pattern element with an illegal repetition factor. For example, the pattern

/^+/

is illegal because the element ^ (beginning of input) cannot have a repetition factor. The following table lists the elements that cannot have repetition factors.

Element

Description

^

Beginning of input

$

End of input

\b

Word boundary

\B

Non-word boundary

*

Zero or more repetitions

+

One or more repetitions

?

Zero or one repetitions

{n}

n repetitions

{n,}

n or more repetitions

{n,m}

From n to m repetitions, inclusive

To correct this error

  • Ensure your search pattern element contains legal repetition factors only.

Show:
© 2015 Microsoft