unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: problem re-search with the \| op.
Date: Thu, 10 Jan 2008 22:35:34 -0500	[thread overview]
Message-ID: <barmar-ADDB53.22353410012008@comcast.dca.giganews.com> (raw)
In-Reply-To: ce71df65-e69f-415b-8d7a-721782e4445f@d70g2000hsb.googlegroups.com

In article 
<ce71df65-e69f-415b-8d7a-721782e4445f@d70g2000hsb.googlegroups.com>,
 rtra <ruitra@gmail.com> wrote:

> Hi,
> 
> I'm having problems searching for a regular expression matching two
> alternatives, A or B.
> A = "#title "
> B = "\* [A-Z][a-z]+.*"
> and allow '.' (dot) to be string concatenation

'.' is string concatenation in Perl, not Lisp.  Lisp does everything 
using functions, not operators like this.  The string concatenation 
function is concat.

> 
> (re-search-backward A 1 t) matches the string A as I intended, and
> (re-search-backward B 1 t) also matches B as intended, but
> (re-search-backward A."\|".B 1 t) does not matches A or B as I thought
> it should

(re-search-backward (concat a "\\|" b) 1 t)

You need to escape the backslash because it has a special meaning in 
strings.

> 
> I'm using GNU Emacs 22.1.1, and testing this with a file like
> ----8<----
> #title test
> * tset
> 
> <point is here>
> ----8<----
> 
> Thank you for you time.
> (I've wasted some in the manual, but I'm not figuring this out...)
> 
> Rui Almeida

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

      reply	other threads:[~2008-01-11  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-10 20:44 problem re-search with the \| op rtra
2008-01-11  3:35 ` Barry Margolin [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-ADDB53.22353410012008@comcast.dca.giganews.com \
    --to=barmar@alum.mit.edu \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).