I\'ve problem with my regex code, the problem is: I want to replace all \"foo\" values but only inside \"()\". Example:
try foo foo-foo (try foo inside , foo
If you can live with using a loop and replacing multiple times, this solution will work:
do { $string = preg_replace('/(\([^)]*)foo([^)]*\))/U', '\1boo\2', $string, -1, $count); }while($count != 0); echo $string;