Re: Find repeating substring



Thus spoke Mike (on 2006-06-20 16:19):

Hmm. This seems very close. It still picks up the code (37.33/2) that
is not repeated, but let me play with this a bit to see if I can
exclude that.

It doesn't here, consider:


my $text = <<END_OF_TEXT;
HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
CATHETER 37.34/2
END_OF_TEXT

my $rep = qr{ ^(.+)(?=\s*).*?\1 }msx;
my ($repeated) = $text=~/$rep/;

print $repeated;



prints: HEART (CONDUCTION DEFECT)


(BTW: I made the final .* non-greedy)

Regards

Mirco
.



Relevant Pages

  • Re: Get regular expression
    ... I would like to get what the actual regular expression is. ... do I gain access to the expression at runtime? ... you want to access the expression "HEART (CONDUCTION DEFECT)" or the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Get regular expression
    ... I would like to get what the actual regular expression is. ... do I gain access to the expression at runtime? ... you want to access the expression "HEART (CONDUCTION DEFECT)" or the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Get regular expression
    ... I would like to get what the actual regular expression is. ... do I gain access to the expression at runtime? ... you want to access the expression "HEART (CONDUCTION DEFECT)" or the ...
    (microsoft.public.dotnet.languages.csharp)
  • Get regular expression
    ... I would like to get what the actual regular expression is. ... DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH ... do I gain access to the expression at runtime? ...
    (microsoft.public.dotnet.languages.csharp)
  • Nashville Nationals - The Adventures of Eric and Richard, Part 3
    ... I hope for something more as we sit down to play the next quarter. ... The opening lead is a spade. ... She now continues a low heart to the East's Queen. ... The opponents continue clubs and Eric wins, ruffs a club, and leads a heart to ...
    (rec.games.bridge)

Loading