I have a Word doc and a front page doc. I am looking to create a script that will look through the 1st document and take any text between two tags (ex: <h1>text text</h1> and then copy it to another file between two tags (say <tr>%text will go here%</tr>.

After the first action was performed, I also need the script to continue through the first document and continue finding tags, take the text from the middle, and then output to a 2nd file.

So 1 document to copy from. Each output will insert into an already existing document between tags (elseif create a new doc).

perl or php will do. I did some searching and the closest I could find was this:

$reg= '/<a NAME=>(.*)<\/a NAME=>/s';
print $matches[1]

But I am not knowledgeable enough to make it work. I've been reading for two days and I do understand the process I just cannot write it.

Many thanks. I wish i had of become a programmer instead of a network administrator :)

Seems I cannot even get the below code to work in php or perl:
$pattern = '/<h2>(.*)<\/h2>/s';
$subject = '<h1>Welcome.</h1> <h2>Welcome to this website.</h2> <p>Some text here. </p>';
preg_match ($pattern, $subject, $matches);
print $matches[1];

Error = Undefined subroutine &main::preg_match called at ./perlconvert.pl line 7.

Please help