[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making a regex string that matches (
From: |
Eric Abrahamsen |
Subject: |
Re: Making a regex string that matches ( |
Date: |
Thu, 10 Mar 2022 09:48:01 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
goncholden <goncholden@protonmail.com> writes:
> ------- Original Message -------
> On Thursday, March 10th, 2022 at 3:51 PM, Robert Pluim <rpluim@gmail.com>
> wrote:
>> > > > > > On Thu, 10 Mar 2022 15:39:03 +0100, Emanuel Berg via Users
>> > list for the GNU Emacs text editor help-gnu-emacs@gnu.org said:
>>
>> Emanuel> angelomolina--- via Users list for the GNU Emacs text editor wrote:
>>
>> >> How can I make a regex string if I want to search for (.
>>
>> Emanuel> Uhm ... how much is a 50¢ stamp?
>>
>> Emanuel> (re-search-forward "(")
>>
>> And since youʼre searching for a literal '(', you can use
>>
>> `search-forward'.
>>
>> Robert
>
> Have come up with the following function. Would this be enough to count the
> number
> oy opening parantheses in a region ?
>
> (defun bracketing-count (region-start region-end)
> "Counts opening and closing bracketing marks.
> Interactive functions enable them to be called using `M-x`"
> (interactive "r") ; gets region start and end
>
> (message "Counting bracketing marks ...")
> (save-excursion
> (let (count)
> (setq count 0)
> (goto-char region-start)
>
> (while (and (< (point) region-end)
> (search-forward "\(" region-end t))
> (setq count (1+ count))) ))))
Not to detract from your achievement, but there's already a
`count-matches' function, if you go back to using a regexp.
Re: Making a regex string that matches (, Leo Butler, 2022/03/10
Re: Making a regex string that matches (, Eduardo Ochs, 2022/03/11