help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to count the number of occurrences of a character in a string?


From: Joost Kremers
Subject: Re: How to count the number of occurrences of a character in a string?
Date: 12 Oct 2015 23:35:26 GMT
User-agent: slrn/1.0.1 (Linux)

Marcin Borkowski wrote:
> the subject line says it all.  Is there any built-in Elisp function to
> do that?

Not that I know of.

>  Should I just use cl-count?

That's one option, if you don't mind depending on cl.

Alternatively, split-string may be of help:

(length (split-string "abcbdbeb" "[^b]" t)) ==> 4 (#o4, #x4, ?\C-d)

But that's rather opaque, so you might want to add a comment to tell
your future self what you're doing here...



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]