Re: find out how many times particular character occur in given string.

From: joel garry <joel-garry_at_home.com>
Date: Thu, 11 Dec 2008 12:46:25 -0800 (PST)
Message-ID: <b4d7be41-cb60-468a-a7db-3330ecf594da@w39g2000prb.googlegroups.com>


On Dec 11, 4:51 am, Noons <wizofo..._at_yahoo.com.au> wrote:
> Radoulov, Dimitre wrote,on my timestamp of 11/12/2008 11:30 PM:
>
>
>
>
>
> > Mladen Gogala wrote:
> >> On Wed, 10 Dec 2008 05:19:20 -0800, Sanjeev wrote:
>
> >>> Dear Gurus,
>
> >>>   I want to find out how many times particular character occur in
> >>> given string.
> >>>   e.g. 'A*B*C*D*E*F' count of '*' is 5
> >>>          'A*B*C*D' count of '*' is 3
> >>>          'A' count of '*' is 0
> > [...]
>
> >> You can also do that in Perl:
>
> >> perl -e '$a="A*B*C*D*E*F"; print scalar(split(/\*/,$a))-1,"\n";'
> > [...]
>
> > Or even:
>
> > perl -le'print shift=~tr/*//' 'A*B*C*D*E*F'
>
> > Regards
> > Dimitre
>
> If someone suggests it in awk,
> I'm gonna have a fit...

Why? Pattern matching is awks reason to live. Maybe Rampant should publish a book <G,D&R>

jg

--
@home.com is bogus.
Christie Hefner resigned.  Playboy Enterprises is cutting costs.
Playboy Magazine loses $10M/year, but that's considered OK because it
is a merchandising vehicle for the rest of the company.  How can
selling pictures of naked ladies lose money?
Received on Thu Dec 11 2008 - 14:46:25 CST

Original text of this message