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

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

regexp newline issue


From: Christopher C. Stacy
Subject: regexp newline issue
Date: Mon, 28 Nov 2005 01:03:19 GMT
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

I want to search for a string like "foo bar",
but there might be whitespace (even newlines)
between any of the characters.

Given the string "foo bar", I tried constructing a regexp by

(replace-regexp-in-string "\\(.\\)"
                            "[\040\011\012\015]*\\1" 
                            "foo bar")

but that doesn't quite do it.

By the way, I originally tried whitespace syntax "\\s-" 
rather than character alternatives, but that seemed to
work even less well.  Also, I am using an older emacs
that does not seem to have the named character classes.

In particular, the above [tab,LF,CR] hack finds #1 and #3,
but not #2, in the following examples:

----------        

1. foo bar

2. foo
bar

-or-

3. fo 
o ba
r
----------

Whenever regexps involve newlines, I get confused.
(OK, I admit I just get confused about almost all regexps!)

TIA for your help!


reply via email to

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