From: Leo Butler <leo.butler@umanitoba.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Making a regex string that matches (
Date: Fri, 11 Mar 2022 06:24:01 -0600 [thread overview]
Message-ID: <8735jovfry.fsf@t14.reltub.ca> (raw)
In-Reply-To: <JO60EMe2_V2IFCKjFg585c3Va1An0uIOVKfYq8A11t2UOLdmjcfIRZRDySFRxT_s4LavmoZbqEddi7RlFL4qVpLTOEUhRQUJpjGT3WzZyHA=@protonmail.com> (goncholden@protonmail.com's message of "Thu, 10 Mar 2022 17:14:57 +0000")
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?
Sarcasm is generally counter-productive.
>
> 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))) ))))
In addition to other points made, your function doesn't deal with corner
cases, such as
\([(]+\)
Should the count be 1 or 2?
Leo
next prev parent reply other threads:[~2022-03-11 12:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 13:36 Making a regex string that matches ( angelomolina--- via Users list for the GNU Emacs text editor
2022-03-10 14:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 15:51 ` Robert Pluim
2022-03-10 17:14 ` goncholden
2022-03-10 17:48 ` Eric Abrahamsen
2022-03-10 17:57 ` [External] : " Drew Adams
2022-03-10 18:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 18:03 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-11 12:24 ` Leo Butler [this message]
2022-03-11 19:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-10 15:13 ` Leo Butler
2022-03-11 23:43 ` Eduardo Ochs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735jovfry.fsf@t14.reltub.ca \
--to=leo.butler@umanitoba.ca \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.