abhishes has asked for the wisdom of the Perl Monks concerning the following question:
The answer getting printed is 6!!! but the answer should be 1. (or 2 if I can make tr/// ignore the case).use warnings; use strict; my $str = "The quick brown fox jumps over the lazy dog"; my $count = ($str =~ tr/(the)//); print "$count\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: counting the number of occurrances of a word using regex
by Ovid (Cardinal) on Dec 03, 2002 at 06:10 UTC | |
by Abigail-II (Bishop) on Dec 03, 2002 at 12:40 UTC | |
by Ovid (Cardinal) on Dec 03, 2002 at 16:46 UTC | |
|
Re: counting the number of occurrances of a word using regex
by BrowserUk (Patriarch) on Dec 03, 2002 at 06:06 UTC | |
|
Re: counting the number of occurrances of a word using regex
by graff (Chancellor) on Dec 03, 2002 at 05:40 UTC | |
|
Re: counting the number of occurrances of a word using regex
by Enlil (Parson) on Dec 03, 2002 at 05:52 UTC | |
|
Re: counting the number of occurrances of a word using regex
by djantzen (Priest) on Dec 03, 2002 at 05:41 UTC |