in reply to CSV cleanup problem...
$_ = q("title", "Some Name, "some weird title"", "555-555-5555"); s/", "/","/g; s/(?<=[^,])"(?=[^,])/""/g; print "$_\n"; __END__ "title","Some Name, ""some weird title""","555-555-5555"
Hope this helps!
Update: Oh yeah, the logic in the regex: any quote that isn't preceded or succeeded by a comma is probably embedded. However, this relies on there not being any properly embedded quotes, but this is necessary. After all, does "foo""bar" contain one or two quotes? Given that the input is not properly embedded, it is not clear.
|
|---|