rednebmas Posted December 21, 2010 Share Posted December 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/222272-recursive-reference-but-part-not-recursive/ Share on other sites More sharing options...
rednebmas Posted December 21, 2010 Author Share Posted December 21, 2010 sqrt(\((?:[^()]++|(?1))+\)) Quote Link to comment https://forums.phpfreaks.com/topic/222272-recursive-reference-but-part-not-recursive/#findComment-1149777 Share on other sites More sharing options...
rednebmas Posted December 21, 2010 Author Share Posted December 21, 2010 Sorry, I can't figure out how to edit apost... This: "sqrt(\((?:[^()]++|(?1))+\))" matches "(5^(x+3)-7)" but I need it to match "5^(x+3)-7". How can I remove the outside parentheses? Quote Link to comment https://forums.phpfreaks.com/topic/222272-recursive-reference-but-part-not-recursive/#findComment-1149782 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.