I have a CSV file and we know excel does its thing with commas in a field by enclosing them in double quotation marks for instance i have a file
Product Name,Product Code
Product 1,AAA
"Prod,A,B",BBB
How can I use RegExp to replace the quotation marks with “.” instead but only within quotation marks so i get
Product Name,Product Code
Product 1,AAA
Prod.A.B,BBB
as output
CSV handling functions (
fgetcsv(),fputcsv()) are much better for this – they will handle edge cases and will likely be far more reliable than any regex you can come up with.EDIT Following your comment about not wanting to read from/write to disk, you can do this: