From: John Paul Wallington <jpw@pobox.com>
Subject: Re: regexp newline issue
Date: Mon, 28 Nov 2005 05:22:54 +0000 [thread overview]
Message-ID: <uk6etny6p.fsf@FILTH.SHOOTYBANGBANG.COM> (raw)
In-Reply-To: <uoe45nzy8.fsf@FILTH.SHOOTYBANGBANG.COM> (John Paul Wallington's message of "Mon, 28 Nov 2005 04:44:47 +0000")
I wrote:
>> 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.
>
> I think you wanna zap all the whitespace chars from your "foo bar"
> string first (eg: so that it's "foobar") before doing the
> `replace-regexp-in-string' hack on it.
Hm. If you do want to match on the whitespace within the string
then maybe something like this would do:
(defun cons-up-regexp (string)
(mapconcat (lambda (char)
(if (memq char '(32 9 10 13))
"[\040\011\012\015]"
(format "[\040\011\012\015]*%c" char)))
string nil))
next prev parent reply other threads:[~2005-11-28 5:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-28 1:03 regexp newline issue Christopher C. Stacy
2005-11-28 4:44 ` John Paul Wallington
2005-11-28 5:22 ` John Paul Wallington [this message]
[not found] ` <mailman.17016.1133155392.20277.help-gnu-emacs@gnu.org>
2005-12-01 4:38 ` Stefan Monnier
2005-11-29 18:23 ` Kevin Rodgers
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=uk6etny6p.fsf@FILTH.SHOOTYBANGBANG.COM \
--to=jpw@pobox.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.
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).