Re: Counting the number of times a string matches in another string

2003-03-13 Thread John W. Krahn
Scott E Robinson wrote: > > Okay, since i wasn't clear the first time, let me try again. Sorry, I'm > not a professional programmer, I'm a true beginner. > > LONG VERSION: > > I think John W. Krahn's post is very close to what I was actually asking. > John's solution showed me that the context

Re: Counting the number of times a string matches in another string

2003-03-13 Thread Rob Dixon
R. Joseph Newton wrote: > Rob Dixon wrote: > > > my $key = ':L000:W000:M260:B271:8:A:'; > > my $regex = join '|', ($candidate =~ m/\w+/g); > > Slick! I like it. It's not my style exactly [I'd at least throw a > comment in: "Set up or for regex"], but it definitely caught my > fancy.<| :-

Re: Counting the number of times a string matches in another string

2003-03-13 Thread R. Joseph Newton
Rob Dixon wrote: > my $key = ':L000:W000:M260:B271:8:A:'; > my $regex = join '|', ($candidate =~ m/\w+/g); Slick! I like it. It's not my style exactly [I'd at least throw a comment in: "Set up or for regex"], but it definitely caught my fancy.<| :-o ) Joseph -- To unsubscribe, e-

Re: Counting the number of times a string matches in another string

2003-03-13 Thread Rob Dixon
Scott E Robinson wrote: > Okay, since i wasn't clear the first time, let me try again. Sorry, > I'm not a professional programmer, I'm a true beginner. Don't apologise for not being a prefessional programmer: some would consider it a thing to be proud of :-) > > SHORT VERSION: > > What I want is

Re: Counting the number of times a string matches in another string

2003-03-13 Thread scott . e . robinson
Okay, since i wasn't clear the first time, let me try again. Sorry, I'm not a professional programmer, I'm a true beginner. SHORT VERSION: What I want is Joseph's option 2b, if I understand him correctly. Given a string of the form :M260: I want to get a count of its occurrences in a single

Re: COunting the number of times a string matches in another string

2003-03-12 Thread John W. Krahn
Scott E Robinson wrote: > > Thanks, Rob and Mark, but I'm pretty sure I'm trying to do something a > little different from a count hash. Each token in the candidate string > needs to be compared separately to all the target strings, and then count > the number of matches. So take any token out o

Re: COunting the number of times a string matches in another string

2003-03-12 Thread R. Joseph Newton
Paul Johnson wrote: > On Wed, Mar 12, 2003 at 03:09:36PM -0800, R. Joseph Newton wrote: > > Mark Anderson wrote: > > > > > > It sounds like you need a count hash. You might try something like: > > > > > > > > my @tokens = split /:/; > > > > foreach (@tokens) { > > > >if ($tokenCount{$_}) {

Re: COunting the number of times a string matches in another string

2003-03-12 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > Thanks, Rob and Mark, but I'm pretty sure I'm trying to do something a > little different from a count hash. Each token in the candidate string > needs to be compared separately to all the target strings, and then count > the number of matches. So take any token out of

RE: COunting the number of times a string matches in another string

2003-03-12 Thread scott . e . robinson
To: <[EMAIL PROTECTED]> .com>cc: Subject: RE: COunting the number

Re: COunting the number of times a string matches in another string

2003-03-12 Thread Rob Dixon
R. Joseph Newton wrote: > Mark Anderson wrote: > > > > It sounds like you need a count hash. You might try something > > > like: > > > > > > my @tokens = split /:/; > > > foreach (@tokens) { > > >if ($tokenCount{$_}) { > > > $tokenCount{$_}++; > > >} else { > > > $tokenCount{$_

Re: COunting the number of times a string matches in another string

2003-03-12 Thread Paul Johnson
On Wed, Mar 12, 2003 at 03:09:36PM -0800, R. Joseph Newton wrote: > Mark Anderson wrote: > > > > It sounds like you need a count hash. You might try something like: > > > > > > my @tokens = split /:/; > > > foreach (@tokens) { > > >if ($tokenCount{$_}) { > > > $tokenCount{$_}++; > > >

Re: COunting the number of times a string matches in another string

2003-03-12 Thread John W. Krahn
"R. Joseph Newton" wrote: > > [EMAIL PROTECTED] wrote: > > > Hi! Maybe this is really easy, but hey, I'm a beginner with Perl. > > > > I'm trying to count the number of times a string is contained inside > > another string. Here's a sample of my data, a set of colon-delimited > > values from th

RE: COunting the number of times a string matches in another string

2003-03-12 Thread Mark Anderson
> > The following works the same and may or may not be easier to > > understand/maintain. > > $tokenCount{$_} is automatically created with a value of 0 when first > > called, and > > then is incremented to 1, so you don't have to test or create it yourself. > > > > my @tokens = split /:/; > > f

Re: COunting the number of times a string matches in another string

2003-03-12 Thread R. Joseph Newton
Mark Anderson wrote: > > It sounds like you need a count hash. You might try something like: > > > > my @tokens = split /:/; > > foreach (@tokens) { > >if ($tokenCount{$_}) { > > $tokenCount{$_}++; > >} else { > > $tokenCount{$_} = 1; > >} > > } > > The following works th

RE: COunting the number of times a string matches in another string

2003-03-12 Thread Mark Anderson
> It sounds like you need a count hash. You might try something like: > > my @tokens = split /:/; > foreach (@tokens) { >if ($tokenCount{$_}) { > $tokenCount{$_}++; >} else { > $tokenCount{$_} = 1; >} > } The following works the same and may or may not be easier to unders

Re: COunting the number of times a string matches in another string

2003-03-12 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > Hi! Maybe this is really easy, but hey, I'm a beginner with Perl. > > I'm trying to count the number of times a string is contained inside > another string. Here's a sample of my data, a set of colon-delimited > values from the Perl Soundex function, with a few pure nu