I am looking for a pattern to match numbers from an expression that have exponents and are enclosed in ():
(64²xy) should match 64²
(6xy/-2²³xy) should match -2²³
(64²xy/2²yx) should match 64² and 2²
(6xy/-2²³+ab) should match -2²³
6xy/-2²³xy should not match anything as the expression is not enclosed in ()
The closest I have come to solving this is "([\-]?[0-9]+[°¹²³]+)". This pattern matches all of the above example text but I only want it to match the first four examples.
Finally I would like to replace the matched text with a number that solves the exponent.