From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Is it valid to use the zero-byte "^@" in regexps?
Date: Wed, 18 Jun 2014 11:52:11 +0200 [thread overview]
Message-ID: <8761jysfxw.fsf@geodiff-mac3.ulb.ac.be> (raw)
In-Reply-To: <87sin2zijl.fsf@gmail.com> (Thorsten Jolitz's message of "Wed, 18 Jun 2014 11:14:06 +0200")
Thorsten Jolitz <tjolitz@gmail.com> writes:
> To rule out a fundamental problem - is it valid to have the zero-byte
> (inserted with C-q C-@) appear in a regexp like this?
>
> ,--------------------------------------------------------
> | "^#\\+begin_src[[:space:]]+emacs-lisp[^^@]*\n#\\+end_src"
> `--------------------------------------------------------
I don't see why it wouldn't be valid, but I don't know. If it is
desirable is another question : it would be better to search for the
beginning, then search for the end with another regexp.
> If so, this regexp should reliably match any
>
> ,-----------------------
> | #+begin_src emacs-lisp
> | [...]
> | #+end_src
> `-----------------------
From the first occurrence of
#+begin_src emacs-lisp
;; after point to the last occurence of
#+end_src
in the buffer. If there's more than one, they'll be part of the match
too. e.g. if there's another block in the same document :
#+begin_src sh
echo whatever.
#+end_src
it'll be part of the match too. If you don't want that, make the star
non-greedy by appending a question mark to it:
(re-search-forward "^#\\+begin_src[[:space:]]+emacs-lisp[^^@]*?\n#\\+end_src")
> no matter whats inside the block, right?
Except NUL characters of course.
--
Nico.
next prev parent reply other threads:[~2014-06-18 9:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 9:14 Is it valid to use the zero-byte "^@" in regexps? Thorsten Jolitz
2014-06-18 9:52 ` Nicolas Richard [this message]
2014-06-18 10:22 ` Thorsten Jolitz
2014-06-18 10:55 ` Nicolas Richard
2014-06-18 11:16 ` Thorsten Jolitz
2014-06-18 11:38 ` Michael Albinus
2014-06-18 12:15 ` Nicolas Richard
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=8761jysfxw.fsf@geodiff-mac3.ulb.ac.be \
--to=theonewiththeevillook@yahoo.fr \
--cc=help-gnu-emacs@gnu.org \
--cc=tjolitz@gmail.com \
/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.