Using Sub-Filters in Search and Replace

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
scrandal
Posts: 7
Joined: Wed Jun 01, 2011 4:54 am

Using Sub-Filters in Search and Replace

Post by scrandal »

I'm not sure if I'm making proper use of Textpipe's search and replace subfilters...

I would like to (1) search for a line of code (2) store some the code in variables (3) IF and only IF the line of code is found THEN (4) cut and move the code to the end of the HTML document.

I've displayed my filters below, and it's the subfilter that isn't working: (the variable capture- @name and @clipboard- IS working).

I only want textpipe to perform the subfilter IF the parent filter is "TRUE". Is there a way to do that?

Note: The filters DO work if I "promote" the second one so that it's not a subfilter, BUT I need the filters to perform as an "IF/THEN" query. Only SOME of the files that I will be processing will have this line of code:
<p><b>Content Author: </b>"Author's Name"</p>.

EasyPattern [<p><b>Content [capture(1 or more characters) as 'name']:</b> [capture(1 or more characters) as 'clipboard']</p>] with []
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [X] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
| Maximum text buffer size 4096
|
+--Perl pattern [<!-- End Editable Area -->] with [<!-- End Editable Area -->\r\n<p><b>Content @name:</b> @clipboard</p>\r\n]
[ ] Match case
[ ] Whole words only
[ ] Case sensitive replace
[X] Prompt on replace
[ ] Skip prompt if identical
[ ] First only
[ ] Extract matches
Maximum text buffer size 4096
[ ] Maximum match (greedy)
[ ] Allow comments
[X] '.' matches newline
[ ] UTF-8 Support

Thank you very much in advance for your help! -Suzanne
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Using Sub-Filters in Search and Replace

Post by DataMystic Support »

Hi Suzanne,

You need to perform these all as one search/replace that encompasses the original text location as well as its target location.

Code: Select all

<p><b>Content [capture(1 or more characters) as 'name']:</b> [capture(1 or more characters) as 'clipboard']</p>[capture(0+chars) as 'body']<!-- End Editable Area -->
replace with:

Code: Select all

<p><b>
@body<!-- End Editable Area -->\r\n<p><b>Content @name:</b> @clipboard</p>\r\n
scrandal
Posts: 7
Joined: Wed Jun 01, 2011 4:54 am

Re: Using Sub-Filters in Search and Replace

Post by scrandal »

Thank you - this works well!

Question for you: does the Easy Pattern language support if/then statements?
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Using Sub-Filters in Search and Replace

Post by DataMystic Support »

No - not pattern matching language supports if/then.

But you can generally express it using the approach above, or uniquely in TextPipe, by using subfilters to restrict to say, a line range, then a column range, or a html element followed by an attribute.
Post Reply