Literally:

length( gregexpr(";", b)[[1]])

But more generally, in case b has more than one element:

sapply(gregexpr(";", b), length)

?gregexpr



On Mon, Oct 11, 2010 at 3:18 PM, Santosh Srinivas <
santosh.srinivas@gmail.com> wrote:

> New to R ... which is a function to most effectively search the number of
> occurrences of a character in a string?
>
> b <-
> c("jkhrikujhj345hi5hiklfjsdkljfksdio324j';;'lfd;g'lkfit34'5;435l;43'5k")
>
> I want the number of semi-colons ";" in b?
>
> Thanks.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner@gmail.com

	[[alternative HTML version deleted]]

