From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Paul Wallington Newsgroups: gmane.emacs.help Subject: Re: regexp newline issue Date: Mon, 28 Nov 2005 05:22:54 +0000 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1133155424 6057 80.91.229.2 (28 Nov 2005 05:23:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Nov 2005 05:23:44 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 28 06:23:29 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EgbU3-00040I-Af for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2005 06:23:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EgbU2-0004SK-Os for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2005 00:23:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EgbTq-0004SE-Ke for help-gnu-emacs@gnu.org; Mon, 28 Nov 2005 00:23:10 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EgbTp-0004S2-3z for help-gnu-emacs@gnu.org; Mon, 28 Nov 2005 00:23:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EgbTp-0004Rz-1T for help-gnu-emacs@gnu.org; Mon, 28 Nov 2005 00:23:09 -0500 Original-Received: from [208.210.124.75] (helo=thorn.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EgbTp-0001vF-38 for help-gnu-emacs@gnu.org; Mon, 28 Nov 2005 00:23:09 -0500 Original-Received: from thorn (localhost [127.0.0.1]) by thorn.pobox.com (Postfix) with ESMTP id 50EE4A7 for ; Mon, 28 Nov 2005 00:23:30 -0500 (EST) Original-Received: from FILTH.SHOOTYBANGBANG.COM (FILTH.SHOOTYBANGBANG.COM [217.169.11.183]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by thorn.sasl.smtp.pobox.com (Postfix) with ESMTP id EE81070F for ; Mon, 28 Nov 2005 00:23:29 -0500 (EST) Original-To: help-gnu-emacs@gnu.org X-Mailer: Norman X-Attribution: JPW X-Face: #uahb@^mo@bA"{q'"a4y[w$n3/V:haD\; YenWcT7)kXYx3/>#[DD9ExVe}; 9FG6X`l!Dm"V peub=u!&&?}s~{TOPtGdH)KA}/qCr; d"Gr*'9_V1PE@+K'tk2/Iq@PBKtJ+]&,CP9_Fl8'*R]LCR0| 6q; Xey'`:DX+)S.]p[KP^sNe`8B\W6(Nw{o5i)y+I!h=0bU5L`Tj`~Q0!G"t(s7o7eh)J\>P>,!~/w $$jGEVa%H%8(jTv In-Reply-To: (John Paul Wallington's message of "Mon, 28 Nov 2005 04:44:47 +0000") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:31450 Archived-At: 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))