slloyd has asked for the wisdom of the Perl Monks concerning the following question:
use strict; my $str='abc%def%.%'; #Get the count by removing all but the percent sign my $pstr=$str; $pstr=~s/[^\%]//sg; my $pcount=length($pstr); print "str: $str\n"; print "pstr: $pstr\n"; print "pcount: $pcount\n";
-------------------------------
by me
http://www.basgetti.com
http://www.kidlins.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting how many times a character is in a string.
by Aristotle (Chancellor) on Nov 18, 2005 at 16:15 UTC | |
|
Re: Counting how many times a character is in a string.
by prasadbabu (Prior) on Nov 18, 2005 at 16:16 UTC | |
|
Re: Counting how many times a character is in a string.
by Samy_rio (Vicar) on Nov 18, 2005 at 16:20 UTC | |
|
Re: Counting how many times a character is in a string.
by marto (Cardinal) on Nov 18, 2005 at 16:20 UTC | |
|
Re: Counting how many times a character is in a string.
by davidrw (Prior) on Nov 18, 2005 at 17:06 UTC | |
|
Re: Counting how many times a character is in a string.
by thundergnat (Deacon) on Nov 18, 2005 at 17:53 UTC | |
by Aristotle (Chancellor) on Nov 18, 2005 at 18:21 UTC | |
by bart (Canon) on Nov 19, 2005 at 14:36 UTC |