Regex to match CSV file nested quotes

Posted by user361970 on Stack Overflow See other posts from Stack Overflow or by user361970
Published on 2010-06-09T02:04:43Z Indexed on 2010/06/09 2:12 UTC
Read the original article Hit count: 261

Filed under:
|
|

Hi,

I know this has been discussed a million times. I tried searching through the forums and have seen some close regex expressions and tried to modify them but to no avail.

Say there is a line in a csv file like this:

"123", 456, "701 "B" Street", 910

Is there an easy regex to detect "B" (since its a non-escaped set of quotes within the normal CSV quotes) and replace it with something like \"B\" ? The final string would end up looking like this:

"123", 456, "701 \"B\" Street", 910

Help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about java

Related posts about regex