In the following string:
(10+10)*2*((1+1)*1)√(16)+(12*12)+2
I am trying replace ((1+1)*1)√(16)
with nthroot(16,(1+1)*1)
.
Specifically, I want to extract everything in the first sets of brackets on each side of the √
.
The brackets themselves could contain many layers of brackets and many different symbols.
Language is JavaScript.
I tried a couple things like <str>.replace(/\((.+)\)√\((.+)\)/g, 'nthroot($1,$2)')
but every one of my attempts at learning RegEx fails and I can't figure this out.