I want to remove comma from string value of comma separated values.
I am parsing mysql insert queries for my project, and i am failing when string value contains comma.
I am working in php.
Example :
$temp = "INSERT INTO temp_table VALUES(1,'name','some random, address')";
as in above example, i want to remove the comma between some random
and address
.
Actually queries contains too many fields and complex values.
UPDATE
I hadn't mentioned my problem in depth, regrets.
I am reading from a mysql dump file, fetching insert queries in one array, then parsing each query.
SOLUTION
preg_replace("/,(?!(?:[^']*'[^']*')*[^']*$)/", '', $var_name);
will do the work, Thanks @Avinash Raj & @MarkusQ