I'm new to regular expressions in JavaScript, and I cannot get a regex to work. The error is:
Uncaught SyntaxError: Invalid regular expression:
/(.*+x.*+)=(.++)/
: Nothing to repeat
I know there are many questions like this other than this, but I cannot get this to work based on other people's answers and suggestions.
The regex is:
/(.*+x.*+)=(.++)/
and it is used to match simple equations with the variable x
on one side.
Some examples of the expressions it's supposed to match are (I'm writing a simple program to solve for the variable x
):
240x=70
x+70=23
520/x=2
13989203890189038902890389018930.23123213281903890128390x+23123/2=3
etc.
I'm trying out possessive quantifiers (*+
) because before, the expressions were greedy and crashed my browser, but now this error that I haven't encountered has come up.
I'm sure it doesn't have to do with escaping, which was the problem for many other people.
See Question&Answers more detail:os