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.
passing a variable
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
Re: passing a variable
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
|
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
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>
<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>
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: passing a variable
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.
-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
Thank you for your quick reply - I will try it! -Suzanne
Re: passing a variable
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).