s/ # search for... \( # a literal "(" ( # begin storing what follows (in "$1") [^)]* # zero or more of anything that is *NOT* ")" ) # stop storing in "$1" ; # a semicolon ( # begin storing what follows (in "$2") [^)]* # zero or more of anything that is *NOT* ")" ) # stop storing in "$2" \) # a literal ")" /($1,$2)/gx; # and replace all that with...see below...