Recursive reference but part not recursive
Posted: Mon Dec 20, 2010 10:47 pm
Hey guys, I am trying to capture stuff inside the parentheses. The problem is that it is possible for parentheses to be inside the sqrt.
example string: "sqrt(5^(x+3)-7)"
desired output capture: 5^(x+3)-7
desired output: sqrt{5^(x+3)-7}
The following captures the correct part but it doesn't work if you put sqrt before it.
/\((?:[^()]+|(?R))*\)/
For reference: http://php.net/manual/en/regexp.reference.recursive.php
example string: "sqrt(5^(x+3)-7)"
desired output capture: 5^(x+3)-7
desired output: sqrt{5^(x+3)-7}
The following captures the correct part but it doesn't work if you put sqrt before it.
/\((?:[^()]+|(?R))*\)/
For reference: http://php.net/manual/en/regexp.reference.recursive.php