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: Stefan Monnier
Subject: Re: How to count the number of occurrences of a character in a string?
Date: Mon, 12 Oct 2015 21:18:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>           (setq str (substring-no-properties str (1+ match-pos)))

This will give wrong results for regexp that use things like ^ and \`.

Instead, you should keep using the same `str' and instead pass the
`start' arg to string-match.


        Stefan




reply via email to

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