[Israel.pm] matching in line (fwd) on behalf of Ernst, Yehuda.B

Friedman, Roee RFriedman at ndsisrael.com
Thu Dec 2 07:10:02 PST 2004


You can use backrefernces:

$var1 = "lksdjvhhgaeifgas;dfjnafb";
$var2 = "dlsjfhgq30874riwufh;wdofia";
$var3 = "jsg55555dsbafoiewury20348r7y2-3495";

# Using backreferences
print 1 if $var1 =~ /(\w)\1{4}/;
print 2 if $var2 =~ /(\w)\1{4}/;
print 3 if $var3 =~ /(\w)\1{4}/;

You can change the quantifier as you wish.

Roee

-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il]On
Behalf Of Shlomo Yona
Sent: Thursday, December 02, 2004 4:59 PM
To: perl at perl.org.il
Subject: [Israel.pm] matching in line (fwd) on behalf of Ernst, Yehuda.B


---------- Forwarded message ----------
Date: Thu, 2 Dec 2004 16:32:27 +0200
From: "Ernst, Yehuda" <yernst at nds.com>
Subject: matching in line


Hello!

I need to read a text file line by line and check every line if it has 5 same chars together in it.

if the file looks like this

lksdjvhhgaeifgas;dfjnafb
dlsjfhgq30874riwufh;wdofia
jsg55555dsbafoiewury20348r7y2-3495

only line 3 will be printed

is there a fast way using pattern match to do it?


thanks
Yehuda Ernst
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
***********************************************************************************
Information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the postmaster at nds.com and destroy the original message.
***********************************************************************************




More information about the Perl mailing list