问题
I am trying to match a string, see example, such that a nested parantheses () is replaced by [] so to not break a parser somewhere else. In this case, I would like to replace the $myStr with "Arman; Dario (10040 Druento (Turin), IT)" ...
Thanks in advance!
monte
{x:
$myStr = "Arman; Dario (10040 Druento (Turin), IT)";
$pattern = "/(\()([a-z,A-Z0-9_\&\/\'\-\,\;\:\.\s^\)]+)(\))/";
if (preg_match_all($pattern,$myStr,$matches))
{
print_r($matches);
}
Obviously, I also need to switch match_all to replace.
To summarize:
INPUT
$myStr = "Arman; Dario (10040 Druento (Turin), IT)";
OUTPUT
$myStr = "Arman; Dario (10040 Druento [Turin], IT)";