From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bitterspetey Newsgroups: gmane.emacs.help Subject: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work Date: Sat, 18 Feb 2012 15:30:39 -0800 (PST) Message-ID: <33350095.post@talk.nabble.com> References: <87ehts2ayk.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_53_25997293.1329607839861" X-Trace: dough.gmane.org 1329609124 32300 80.91.229.3 (18 Feb 2012 23:52:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 18 Feb 2012 23:52:04 +0000 (UTC) To: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 19 00:52:04 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ryu4M-00019X-Nn for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Feb 2012 00:51:58 +0100 Original-Received: from localhost ([::1]:39987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ryu4L-0004Lj-Ru for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Feb 2012 18:51:57 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rytjm-0008Rd-PG for Help-gnu-emacs@gnu.org; Sat, 18 Feb 2012 18:30:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rytjl-0001ck-CL for Help-gnu-emacs@gnu.org; Sat, 18 Feb 2012 18:30:42 -0500 Original-Received: from sam.nabble.com ([216.139.236.26]:58153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rytjl-0001ca-79 for Help-gnu-emacs@gnu.org; Sat, 18 Feb 2012 18:30:41 -0500 Original-Received: from isper.nabble.com ([192.168.236.156]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1Rytjj-0000xm-S6 for Help-gnu-emacs@gnu.org; Sat, 18 Feb 2012 15:30:39 -0800 In-Reply-To: <87ehts2ayk.fsf@gmail.com> X-Nabble-From: business@stevepetersen.net X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 216.139.236.26 X-Mailman-Approved-At: Sat, 18 Feb 2012 18:51:54 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83796 Archived-At: ------=_Part_53_25997293.1329607839861 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Thanks for the suggestions so far! query-replace does not seem to work across newlines (to my surprise). foo[\s^J]bar also does not work; I thought \s- was supposed to match any whitespace, including newline, and not be interpreted as part of a range in this case. This one below does work, and thank you! But as you say, it's kludgy. Is this really the best emacs can do to replace a phrase?! Why doesn't \s- work in this context? Is there no way to match any whitespace? Jeremiah Dodds wrote: > > The following works for me with the words separated by arbitrary > whitespace including newlines (although it is ugly, and I'm sure there's > better ways to do it): > > M-x replace-regexp foo[ ^TAB^j]*bar[ ^TAB^j]*baz[ ^TAB^j] RET fbb RET > -- View this message in context: http://old.nabble.com/replacing-phrases%3A-matching-line-feeds-in-regular-expressions%2C-since-%5Cs--doesn%27t-work-tp33349186p33350095.html Sent from the Emacs - Help mailing list archive at Nabble.com. ------=_Part_53_25997293.1329607839861 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Thanks for the suggestions so far!

query-replace does not seem to work across newlines (to my surprise).

foo[\s^J]bar also does not work; I thought \s- was supposed to match any whitespace, including newline, and not be interpreted as part of a range in this case.

This one below does work, and thank you! But as you say, it's kludgy. Is this really the best emacs can do to replace a phrase?! Why doesn't \s- work in this context? Is there no way to match any whitespace?

Jeremiah Dodds wrote:
The following works for me with the words separated by arbitrary whitespace including newlines (although it is ugly, and I'm sure there's better ways to do it): M-x replace-regexp foo[ ^TAB^j]*bar[ ^TAB^j]*baz[ ^TAB^j] RET fbb RET


View this message in context: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work
Sent from the Emacs - Help mailing list archive at Nabble.com.
------=_Part_53_25997293.1329607839861--