Re: Find repeating substring
- From: "Mike" <msgrinnell@xxxxxxxxxxx>
- Date: 20 Jun 2006 11:51:57 -0700
xhoster@xxxxxxxxx wrote:
"Mike" <msgrinnell@xxxxxxxxxxx> wrote:
Please don't top post. Top posting fixed.
xhoster@xxxxxxxxx wrote:
"Mike" <msgrinnell@xxxxxxxxxxx> wrote:
Hi All,
I need a regular expression to find repeating substrings (in
particular the substring that starts in position 1 of the string and
is repeated elsewhere in the string). For example, in the case
below, the substring of interest would be "HEART (CONDUCTION
DEFECT)".
Thanks much for any insights,
Mike
HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
CATHETER 37.34/2
This seems pretty simple. What am I missing?
/^(.*).*\1/s
Xho
Your solution still leaves the code 37.33/2 in the result.
No, it does not.
$ perl -l
$_ = 'HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT)
WITH CATHETER 37.34/2';
if (/^(.*).*\1/) {
print "Result: $1";
}
__END__
Result: HEART (CONDUCTION DEFECT)
See, no 37.33/2 in the result!
Xho
--
Sorry. My mistake. I ran the Perl script with your suggestion and no
37.33/2 (as you noted). As I am trying to also see if this will work
in C# code (on demand) I ran it on Expresso as ^(.*).*\1 against the
same string and it left the code. Different implementation? I only
use regular expressions irregularly and so am merely dangerous with
them.
.
- Follow-Ups:
- Re: Find repeating substring
- From: David Squire
- Re: Find repeating substring
- References:
- Find repeating substring
- From: Mike
- Re: Find repeating substring
- From: xhoster
- Re: Find repeating substring
- From: Mike
- Re: Find repeating substring
- From: xhoster
- Find repeating substring
- Prev by Date: Re: File::Find - passing argument to &wanted
- Next by Date: Spread***::ParseExcel to find out if there is a Strikeout
- Previous by thread: Re: Find repeating substring
- Next by thread: Re: Find repeating substring
- Index(es):
Loading