Hi Barry, I made a slightly bigger test file from your input for testing. ===================================================================== <table class="socialheader" width="100%" border="0"> <tr> <td width="85%" align="left" nowrap>The Three Sisters, Glen Coe</td> </tr> </table> <table class="sociheader" width="100%" border="0"> <tr> <td width="85%" align="left" nowrap>This cannot be used</td> </tr> </table> <table class="socialheader" width="100%" border="0"> <tr> <td width="85%" align="left" nowrap>This is different each time</td> </tr> </table> <table class="socialhear" width="100%" border="0"> <tr> <td width="85%" align="left" nowrap>This is not usable</td> </tr> </table> ========================================================================= I think the perl script below (or some modification thereof) will do what you want. ===================================================== #! /usr/bin/perl use strict; open(INFILE, "<$ARGV[0]"); my $social_flag = 0; while(<INFILE>) { my $line=$_; chomp($line); if($line=~m/\<table class\=\"socialheader\"/) { $social_flag = 1; print("$line\n"); next; } if($line=~m/align\=\"left\"/ and $line=~m/width\=\"85\%\"/ and $line=~m/nowrap/ ) { if($social_flag) { print("$line\n"); print("One new line here\n"); print("Another new line here\n"); $social_flag = 0; } else { print("$line\n"); } } else { print("$line\n"); } } close(INFILE); ============================================================== Hope this helps. Govind
Subject: [ALUG] Search and replace(insert) - can anyone help? To: Alug <main@lists.alug.org.uk> Message-ID: <1288625418.1815.0@dataman1> Content-Type: text/plain; charset=us-ascii
<table class="socialheader" width="100%" border="0">
<tr> <td width="85%" align="left" nowrap>The Three Sisters, Glen Coe</td> </tr>
</table>
I have over 2500 pages with the above HTML in ( the "Three Sisters, Glen Coe" bit is different in every file) and I want to add two lines so:
<table class="socialheader" width="100%" border="0">
<tr> <td width="85%" align="left" nowrap>The Three Sisters, Glen Coe</td> <One new line here> <Another new line here> </tr>
</table>
The pair of lines to be inserted is identical in each case but the only unique identifier is the "class=socialheader".
Is there any way I can do it with a script?
-- Barry Samuels http://www.beenthere-donethat.org.uk The Unofficial Guide to Great Britain