Page 1 of 1

Replace double quotes within double quotes

Posted: Wed Apr 09, 2008 11:14 pm
by encleadus
Hi, tried searching and couldn't find an answer, this is the closest thread I could find: http://forums.textpad.com/viewtopic.php?t=7698

I am trying to find and replace double quotes that are within another set of double quotes between commas with single quotes, i.e.:

Code: Select all

,12344,"text",absd,5830,"This is an, "example of my problem".",1234
,4346,"here is "another example" of the problem.",lded,345435,abde,5365
,9865434,"this is, the "last example". can you help.",abed,5465,"eadd",6786
I am trying to get the output to look like:

Code: Select all

,12344,"text",absd,5830,"This is an, 'example of my problem'.",1234
,4346,"here is 'another example' of the problem.",lded,345435,abde,5365
,9865434,"this is, the 'last example'. can you help.",abed,5465,"eadd",6786
with the double quotes within other double quotes are changed to single quotes.

Within the outer double quotes there are commas, periods, /, and - too. The inner double quotes appear anywhere within the outer double quotes.

I have tried a few things

Code: Select all

,("[^",]*("[^",]*)*"[^",]*."),
and

Code: Select all

,"[^",]*"[^",]*".*",
that seem to match some of the examples, but can't figure out to get it down to just matching/replacing the inner double quotes.

Any ideas?

Posted: Fri Apr 11, 2008 7:47 am
by ben_josephs
This is going to be difficult in TextPad, because its aged regular expression engine is incapable of matching text containing an arbitrary number of newlines. If you must do this in TextPad you will have to change the newlines to something else, do your stuff, then change them back.

Posted: Fri Apr 11, 2008 3:16 pm
by encleadus
By newline, do you mean \n? Each record is on one line; I don't understand why I would have to change newlines to something else?

I was hoping I could do something like

Code: Select all

...,"any or no character"anycharacter"any or no character",...
between the delimiters (commas) find the inner quotes, with any or no characters surrounding the inner quotes and any characters between the inner quotes. By character I mean text, number, etc.

Is this something that could be accomplished in WildEdit? I've never used it before.

Posted: Sun Apr 13, 2008 9:46 am
by ben_josephs
Oh I see. How about
Find what: (,"[^"]*)"([a-z][^"]*)"
Replace with: \1'\2'

[X] Regular expression

Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax

Try DataMystic TextPipe instead

Posted: Mon Apr 14, 2008 10:46 am
by David Haslam
Might I suggest that you consider using DataMystic TextPipe for such a task?I've been using TextPipe Standard for several years, and have been very pleased with it.