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

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

Re: Making a regex string that matches (


From: goncholden
Subject: Re: Making a regex string that matches (
Date: Thu, 10 Mar 2022 17:14:57 +0000

------- 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))) ))))






reply via email to

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