Page 1 of 1

passing a variable

Posted: Wed Jun 01, 2011 5:12 am
by scrandal
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.

Re: passing a variable

Posted: Wed Jun 01, 2011 5:57 am
by scrandal
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
|

Re: passing a variable

Posted: Wed Jun 01, 2011 5:59 am
by scrandal
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>

Re: passing a variable

Posted: Thu Jun 02, 2011 9:58 am
by DataMystic Support
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.

Re: passing a variable

Posted: Thu Jun 02, 2011 11:42 pm
by scrandal
Thank you for your quick reply - I will try it! -Suzanne

Re: passing a variable

Posted: Wed Oct 12, 2011 6:38 am
by scrandal
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).