Currently have /([^\s\+\(]+)\^([^\s\,\+\)]+)/g
to convert x^y
into pow(x,y)
.
Works for:
y = x
y = x^2
y = x^2 + y^2
y = 5*(x^2 + y^2)
y = (x^2 + y^2)
y = pow(x^2+y^2, 2)
However I want to be able to do something like this:
y = abs(x)^2 --> y = pow(abs(x), 2)
I currently have \(
in the first negated capture group to stop 5*(x^2)
being messed up, however what I really want to do is negate *(
as a pair, so the bracket is only negated when preceded by parantheses.
Is there a way to negate specific occurences of consequtive characters?