The best solution would be not to use regexp.
Try a small function that parses your string like that:
(Function in PHP, I don't know what language you're using)
function dotReplacer($string) {
$parenthesis = 0; // Counts if we are inside parenthesis or not.
$listOfDots = array(); // List of the index of the $string which contain dots to replace.
$listOfElements = array(); // List of elements between these dots. e.g.: $MM, Player and Panning(1, 0.1)
$newString = ''; // The new string to return.
for ($i = 0; $i < strlen($string); $i++) { // Check with every character in the $string...
switch (substr($string, $i, 1)) {
case '(':
$parenthesis++; // If we see an opening parenthesis, increase the level.
break;
case ')':
$parenthesis--; // If we see a closing parenthesis, decrease the level.
break;
case '.':
if ($parenthesis == 0) {
$listOfDots[] = $i; // If we see a dot AND we are not inside parenthesis, include the character index in the list to replace.
}
break;
default:
}
}
$iterator = 0; // Beginning at the start of the string...
foreach ($listOfDots as $dot) {
$listOfElements[] = substr($string, $iterator, $dot - $iterator); // Add the element that is between the iterator and the next dot.
$iterator = $dot + 1; // Move the iterator after the dot.
}
$listOfElements[] = substr($string, $iterator); // Do that one more time for everything that takes place after the last dot.
return implode('->', $listOfElements); // Return an imploded list of elements with '->' between the elements.
}
It works perfectly, I tried. Your input and output are correct.