php - Replace commas for enum into pipes -


whats best way replace commas xx(a,s,d,f) pipes in long string like

`exp` x(10) xx('s','44','f','dd','sddd') other text here, text here , other text here 

i want replace commas in xx('s','44','f','dd','sddd') part [commas in brackets]

maybe like:

while (preg_match('/\((.*),(.*)\)/', $foo))     $foo = preg_replace('/\((.*),(.*)\)/', '($1|$2)', $foo); 

Comments