[email protected] <> wrote:
> Hello,
>
> I have to analize a text document and want to get all lines like:
>
>> F<a string>F<another string>F<another string>F<
>> #
> (where F is a floating point number between the two characters >< )
>
> but only, if all four floating numbers are identical!
>
>
> Example for a text:
>
> text>text<text
>> 5.3<abc>5.3<d>5.3<ef>5.3<
>> 4.2<abc>3.0<d>4.2<ef>4.2<
>
> Here, only the second line is needed.
>
>
>
> Some ideas?
Well, the following operates successfully on what you have specified:
-------------------------------------------------
use strict;
use warnings;
my $re = qr{(>[\d.]+<) # match first occurrance
([^<>]+\1)+ # match subsequent occurrances
}x;
while (<DATA>) {
chomp;
if (/^$re$/) {
print "Match: '$_'\n";
}
else {
print "No match: '$_'\n";
}
}
__DATA__
text>text<text
>5.3<abc>5.3<d>5.3<ef>5.3<
>4.2<abc>3.0<d>4.2<ef>4.2<
-------------------------------------------------
HTH
--
Brian Raven
Please consider the environment before printing this email.
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs