Hi Regular Expression Experts,
There has never been a problem with string manipulations that I could not resolve with regular expressions so far, at least elegantly, using only one step. Here is an example of the data I'm working with:
0, "section1", "(7) The supply of a" certificate "outside the State is prohibited. Since both sections 339 of the 1940 statute, 68 and section 341 of this law, in their statement that the certificate should be provided to a citizen only if such person time in the United States, itโs clear that the document could not and cannot be delivered outside the United States. ", http://www.google.com/
1, "section2", http://www.google.com/
2, "section3", ",", http://www.google.com/
This is a section of a much larger CSV file. With one elegant regular expression, I would like to replace only all commas that occur in double quotes with an underscore (_). It is important that the regular expression does NOT replace any commas outside the quotes, because this would ruin the CSV data structure.
Thanks Tom
-
UPDATE:
Sorry guys, I posted the question without fully explaining my situation, so let me summarize below:
- Suppose that the quotation marks in quotation marks are already escaped (the quotation marks in quotation marks in the CSV file saved in Excel are represented by
"" or """ etc., so they are easily replaced in advance). - I work in JavaScript.
Using the example text above, this is what it should look like after starting a regular expression replacement (there should be only 5 replacements):
0, "section1", "(7) The delivery of a" certificate "outside the State is prohibited. Since both sections 339 of the 1940 statute 68 and section 341 of this law in their statement that the certificate should be provided to the citizen_ only if such person is in time in the United States, it is clear that the document could not and cannot be delivered outside the United States. ", Http://www.google.com/
1, "section2", http://www.google.com/
2, "section3", "__", http://www.google.com/