[Top][All Lists]

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

Re: problem re-search with the \| op.

From: Barry Margolin
Subject: Re: problem re-search with the \| op.
Date: Thu, 10 Jan 2008 22:35:34 -0500
User-agent: MT-NewsWatcher/3.5.3b2 (PPC Mac OS X)

In article 
 rtra <> 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 

> 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,
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 via email to

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