Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Re: Patter Finding

by demerphq (Chancellor)
on Sep 11, 2001 at 15:29 UTC ( #111715=note: print w/replies, xml ) Need Help??

in reply to Re: Patter Finding
in thread Pattern Finding

Well George I came up with the same number of 'patterns' but I didnt need a regex. I thought you might like to see it:
my $s='helloworldhellohellohihellohiworld'; #determine every substring in the original my %hash; for my $i (0..length($s)-1) { $hash{substr($s,$i,$_)}++ for (1..length($s)-$i); } #filter out singles and the chars %hash=map { ($hash{$_}>1 && length($_)>1) ? ($_,$hash{$_}) :() } keys %hash; #yes this is how i format maps #and ternary ops.. :-) #print the results use Data::Dumper; print Dumper(\%hash);
Id love to know how the OP wanted the computer to tell that 'hello' is a word but 'elloh' isnt... (forgetting real english words that are embedded like 'low' 'el' 'hell')

Incidentally get the following results (reformatted):

el,ell,ello,elloh,ellohi, he,hel,hell,hello,helloh,hellohi,hi, ld,ll,llo,lloh,llohi,lo,loh,lohi, oh,ohi,or,orl,orld, rl,rld,wo,wor,worl,world
I have a feeling there isn't really a way to do what the OP wants to do. Its not really prefix matching, nor suffix matching....

To the OP what should happen here if said 7 words? 'hellohiothellobrakerakerashash'

You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Update minor bugfixes and challenge to Op

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://111715]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-25 12:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.