got it! very nice, not complicated at all. I didn't know about lookahead
feature. very useful.
this file that should be matched:
<TABLE>
<TR><TD>row 1</TD></TR>
<TR><TD>row 2</TD></TR>
<TR><TD>row 3</TD></TR>
<TR><TD>Bug some word</TD></TR>
<TR><TD>row 4</TD></TR>
<TR><TD>row 5</TD></TR>
</TABLE>
this is file that should not be matched:
<TABLE>
<TR><TD>row 1</TD></TR>
<TR><TD>row 2</TD></TR>
<TR><TD>row 3</TD></TR>
<TR><TD>Bug some word</TD></TR>
<TR><TD>row 4</TD></TR>
<TR><TD>row 5</TD></TR>
<TR><TD>row 6</TD></TR>
</TABLE>
this is solution:
#!/usr/bin/perl
use warnings;
use strict;
my $file;
while(<>){
$file .= $_;
}
if ($file =~
m{(Bug(?:(?!<TR>).)*)</TR>\s+(<TR>(?:(?!<TR>).)*</TR>\s*){2}<\/TABLE>}s){
print "matched: $1\n";
}
else{
print "failed\n";
}
this is run:
$ regex.pl file1.txt
matched: Bug some word</TD>
$ regex32.pl file2.txt
failed
thanx everyone!
On 10/13/06, Paul Johnson <[EMAIL PROTECTED]> wrote:
On Fri, Oct 13, 2006 at 12:36:33PM -0500, Charles K. Clarkson wrote:
> I.B. wrote:
>
> : unfortunately I have to use regex to solve this problem.
>
> Why do you have to use a regex?
Because that is what the question stipulates.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>