Page 1 of 1

Replace all ' and " on a multi-line text

Posted: Wed Mar 12, 2008 11:05 pm
by gerd
I have just a small trial and error knowledge of regex patterns. My Problem: I want to eliminate the two characters (' ") with no replacement from a multi-line text. The multi-line text starts with
showTooltip(event,'
and ends with
');return false

All ' and " cause the tooltips to fail.
I have tried something with * in pattern style but my knowledge ist to small.
My settings are:
Find type: (Pattern (perl) and Action: Replace
So I am looking for help what to put in
textbox "Find Pattern (perl-style)"
and in textbox "Replace with"
I am not asking for a one-step-solution. I think it is easier to do the elimination in two steps.
thanks

Posted: Thu Mar 13, 2008 8:02 am
by DataMystic Support
Set your first pattern to find perl pattern:

Code: Select all

showTooltip(event,'.*');return false
Replace with

Code: Select all

$0
Add a new search/replace and drag it inside the first one. Set it's perl pattern to:

Code: Select all

['"]
Replace with nothing

Posted: Fri Mar 14, 2008 3:00 am
by gerd
Simon,
Thanks for your prompt advice.
I still have the problem that all ' and " characters are replaced and not only such characters WITHIN the above specified part of the entire text.
I have illustrated the problem with two screenshots of the settings in Textpipe and have added some explanatory text. Would you please have a look at it. Maybe this is more specific.
http://quiz-center.de/tp.htm
thanks gerd

Posted: Fri Mar 14, 2008 7:04 am
by DataMystic Support
You need to drag the second search replace INSIDE the first one (in the tree view) as a subfilter. Please see the Tutorials in the Help menu

Posted: Fri Mar 14, 2008 8:06 pm
by gerd
Simon,
I consulted the tutorials again but I am still struggling with the problem.
I have added a new screenshot which illustrates what I did.
http://quiz-center.de/tp.htm

I still get as an output that all of ' and " are replaced or none. Is there a chance to get a filter (.fll) by mail for it or may I call Australian support for it? Almost all my complicated Search & replace requests refer to subfilters which define a specific part of text in files to be searched and replaced. That is why I am very keen to know how it works.
thanks gerd

Posted: Mon Mar 17, 2008 7:33 am
by DataMystic Support
Ok, the problem here is that it's only the text within the single quotes that needs to be subfiltered.

Change the pattern to:

Code: Select all

showTooltip(event,'(.*)');return false
and set the Action field to 'Send variable 1 to subfilter'.

This will prevent the initial and final single quote from being included. Turn on 'Prompt On Replace' to see it working

Posted: Mon Mar 17, 2008 7:11 pm
by gerd
It does not work neither this way or any other way.
I will probably give it up. I added the new screenshots and the example file
example text file
to demonstrate that it does not work this way. Thus, I have to do it manually or to consult a php or perl expert to do this in perl or php. This brings me to the question:

Replace given keywords from csv file into clickable URLs

which I will put into a new thread because I think this might interest quite a few people.
gerd

Posted: Tue Mar 18, 2008 9:56 am
by DataMystic Support
Ahh - I see the problem. The top replace filter should be

Code: Select all

showTooltip\(event,'(.*)'\);return false
because the ( and ) are special characters.

It works perfectly for me now!

Posted: Tue Mar 18, 2008 8:06 pm
by gerd
Simon,
and now it works perfectly for me as well. We made it.
Thanks for the support.
gerd