From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.help Subject: Re: Is it valid to use the zero-byte "^@" in regexps? Date: Wed, 18 Jun 2014 11:52:11 +0200 Message-ID: <8761jysfxw.fsf@geodiff-mac3.ulb.ac.be> References: <87sin2zijl.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1403085086 26012 80.91.229.3 (18 Jun 2014 09:51:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Jun 2014 09:51:26 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thorsten Jolitz Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 18 11:51:17 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WxCWQ-0003WF-Tv for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Jun 2014 11:51:15 +0200 Original-Received: from localhost ([::1]:56098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxCWQ-0007g3-Ij for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Jun 2014 05:51:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxCW6-0007ey-JE for help-gnu-emacs@gnu.org; Wed, 18 Jun 2014 05:51:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxCVz-0008GZ-4L for help-gnu-emacs@gnu.org; Wed, 18 Jun 2014 05:50:54 -0400 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:27503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxCVy-0008GJ-Uk for help-gnu-emacs@gnu.org; Wed, 18 Jun 2014 05:50:47 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjwFAFhgoVOkD4Xx/2dsb2JhbABarkYBAQEBAQEGmSgBgSJ1hAMBAQQBeQULCw4TJQ8BBA08E4gtAQMJCK5clgwBSg2GNheFYoIFhGuCIweEQwSYSohchnWGAINEOw Original-Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3.ulb.ac.be) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 18 Jun 2014 11:50:44 +0200 In-Reply-To: <87sin2zijl.fsf@gmail.com> (Thorsten Jolitz's message of "Wed, 18 Jun 2014 11:14:06 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 164.15.128.112 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98325 Archived-At: Thorsten Jolitz 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.