Regular expression: Preceding token is not quantifiable
12,111
+
is a special character, a quantifier, that specifies the multiplicity of the element before. For example a+
means that there should be at least one a
, up to any number of a
s. If you want to match the plus character itself, you will have to escape it:
(-|\+)?
In your case, as you are only considering two different characters, you can also use a character class and specify the two characters that way. Then you don’t need to escape it:
[-+]?
Author by
VN1992
Updated on June 04, 2022Comments
-
VN1992 almost 2 years
I have a regular expression
(-|+)?
, but when I ran it on regex101.com I get the error:+: Preceding token is not quantifiable
What does the error mean? Thank you