passing a variable

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

passing a variable

Postby scrandal » Wed Jun 01, 2011 5:12 am

Hi - I'm a new user and I'm trying to figure out how to capture and pass a variable from one filter to another (sub-filter).

I'm using the following Perl expression to initially find the HTML code:
<p><b>Content Author:</b>(.*)</p>. (Note: the Content Author is different per each HTML file)

At this point I would like to delete this line of code, but store the results of (.*) in a variable so that I can use it in a subsequent filter which searches for another section of code and replaces it with <p></b>Content Author:</b>@VARIABLE</p>. Essentially, my goal is to remove the line of code from one area and then re-apply it to another area of the HTML document.

Is this possible? Thank you, in advance, for your help and support.

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

Re: passing a variable

Postby scrandal » Wed Jun 01, 2011 5:57 am

This is my attempted Filter List:

Filter List
-----------
Filter options
| [ ] Log to file
| [X] Append to logfile
| Log filename: textpipe.log
| Threshold 500
|
|--Input from file(s)
| [ ] Confirm before processing each file
| [ ] Confirm before processing read/only files
| [ ] Delete input files after processing
| Process binary files
|
|--Perl pattern [<p><b>Content Author:</b>(.*)</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
| | [ ] Maximum match (greedy)
| | [ ] Allow comments
| | [X] '.' matches newline
| | [ ] UTF-8 Support
| |
| |--Capture to variable @text
| | Reset: 1
| |
| +--Perl pattern [<DIV ID="disclaimer">(.+)</DIV>] with [<p><b>Content Author:</b> @text</p>]
| [ ] 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
|

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

Re: passing a variable

Postby scrandal » Wed Jun 01, 2011 5:59 am

This is my code:

<HTML>
<TITLE>Lecture</TITLE>
<HEAD>
</HEAD>
<BODY>

<!-- Begin Editable Area -->

<H1>Course Lecture 1-1 The Financial Markets and U.S. Domestic Economy</H1>

<p><b>Content Author:</b> Greg Todd, MA, MSF, CMA</p>

<P>Please view the following 9 minute presentation.</P>

<!-- Enter Presentation Script Here -->

<!-- End Editable Area -->

<DIV ID="disclaimer"><B>Please click on the next item in the packet.</B><BR>
<I>© Walsh College, All rights reserved</I></DIV>

</BODY>
</HTML>

User avatar
DataMystic Support
Site Admin
Posts: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: passing a variable

Postby DataMystic Support » Thu Jun 02, 2011 9:58 am

The problem is that you are removing the text before you capture it:
-Perl pattern [<p><b>Content Author:</b>(.*)</p>] with []

You need to capture first, remove second.

So instead, set this perl pattern's Action to send $1 to the subfilter.

Then copy the perl pattern to remove the text, as you have done above.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: passing a variable

Postby scrandal » Thu Jun 02, 2011 11:42 pm

Thank you for your quick reply - I will try it! -Suzanne

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

Re: passing a variable

Postby scrandal » Wed Oct 12, 2011 6:38 am

yes, i posed the question differently and received a workable answer. search for posting: "Using Sub-Filters in Search and Replace" (or view my posts).


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 3 guests