Extract several parts of a line
Posted: Thu Sep 16, 2010 8:52 pm
Hi,
I have tried a couple of things with Perl pattern to extract some parts from the following lines of sample text. In Detail: I would like to extract 3 parts of the line and combine the extraced $ parts in a new line. The parts are here:
- text between href="..."
- text between title="..."
and if it would even be possible text between first >...<span>
Sample Text:
<div class="tab"><a target="_top" href="viewforum.php?f=17&start=100" title="Page 3 TEST">Linktext Example John<span></span></a></div>
<div class="tab"><a title="Page 2 text" target="_top" href="viewforum.php?f=17&start=50" >Linktext Example Bob<span></span></a></div>
Required results:
<a title="Page 3 TEST" class="" href="viewforum.php?f=17&start=100">Linktext Example John</a>
<a title="Page 2 text" class="" href="viewforum.php?f=17&start=50">Linktext Example Bob</a>
I assume that such a "Replace" will not work.
Repace with <a title="$1" class="" href="$2">$3</a>
So far, I have only managed to use separate filters like
title="(.*)"
href="(.*)"
output to clipboard and copyafter afterwards the results in two different columns in an excel file and combine them in a third column. I guess it will work with Textpipe safer and quicker but I do not know any further. Could show me the filter?
thanks gerd
I have tried a couple of things with Perl pattern to extract some parts from the following lines of sample text. In Detail: I would like to extract 3 parts of the line and combine the extraced $ parts in a new line. The parts are here:
- text between href="..."
- text between title="..."
and if it would even be possible text between first >...<span>
Sample Text:
<div class="tab"><a target="_top" href="viewforum.php?f=17&start=100" title="Page 3 TEST">Linktext Example John<span></span></a></div>
<div class="tab"><a title="Page 2 text" target="_top" href="viewforum.php?f=17&start=50" >Linktext Example Bob<span></span></a></div>
Required results:
<a title="Page 3 TEST" class="" href="viewforum.php?f=17&start=100">Linktext Example John</a>
<a title="Page 2 text" class="" href="viewforum.php?f=17&start=50">Linktext Example Bob</a>
I assume that such a "Replace" will not work.
Repace with <a title="$1" class="" href="$2">$3</a>
So far, I have only managed to use separate filters like
title="(.*)"
href="(.*)"
output to clipboard and copyafter afterwards the results in two different columns in an excel file and combine them in a third column. I guess it will work with Textpipe safer and quicker but I do not know any further. Could show me the filter?
thanks gerd