Replace double quotes within double quotes

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
encleadus
Posts: 5
Joined: Wed Jul 25, 2007 5:02 pm

Replace double quotes within double quotes

Post 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?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
encleadus
Posts: 5
Joined: Wed Jul 25, 2007 5:02 pm

Post 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.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
David Haslam
Posts: 24
Joined: Wed Oct 01, 2003 2:24 pm
Location: United Kingdom
Contact:

Try DataMystic TextPipe instead

Post 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.
Best regards,

David F Haslam, MA, CEng, MIEE
Post Reply