From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#12622: replace-regexp-in-string Date: Thu, 11 Oct 2012 16:17:24 +0200 Message-ID: <5076D4F4.2020404@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1349965114 16448 80.91.229.3 (11 Oct 2012 14:18:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2012 14:18:34 +0000 (UTC) To: 12622@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 11 16:18:40 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TMJay-00027v-5W for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2012 16:18:40 +0200 Original-Received: from localhost ([::1]:37327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJar-0005vr-PM for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2012 10:18:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJaj-0005uR-71 for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:18:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMJad-0001Im-2n for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:18:25 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJac-0001Ii-Vb for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:18:19 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TMJbK-0003xL-U3 for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:19:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Oct 2012 14:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12622 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.134996512715181 (code B ref -1); Thu, 11 Oct 2012 14:19:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Oct 2012 14:18:47 +0000 Original-Received: from localhost ([127.0.0.1]:39572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TMJb2-0003wm-67 for submit@debbugs.gnu.org; Thu, 11 Oct 2012 10:18:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52070) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TMJay-0003wW-Sw for submit@debbugs.gnu.org; Thu, 11 Oct 2012 10:18:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMJa5-0001BZ-1X for submit@debbugs.gnu.org; Thu, 11 Oct 2012 10:17:50 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:46840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJa4-0001BV-UZ for submit@debbugs.gnu.org; Thu, 11 Oct 2012 10:17:44 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJZz-0005dN-6c for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:17:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMJZv-0001A6-4L for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:17:39 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.186]:63765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMJZu-00019E-R5 for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2012 10:17:35 -0400 Original-Received: from [192.168.178.27] (brln-4d0c3908.pool.mediaWays.net [77.12.57.8]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0LrsY2-1TVUvK3s90-0135yN; Thu, 11 Oct 2012 16:17:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120825 Thunderbird/15.0 X-Provags-ID: V02:K0:tDS4qQxDnAZlj4+iUPulvaCgWx2Msx/4zCtD3L/qE6G OKYjoKLxBGI0Zt6sMSp+Cl9tmMTSiA0/x5+k8e0TRKVBo0DCcl eWFYBoMLFzBXLU+Hk7t2bR05j2kz2asUL7bsl24PRc45cUWTET Fk9ciS8Wlyfo9Eo4WQpgoNmI+YV7QmrqZlHBjJYb6ggceoYwXj u+Dpuf5gubgJ7lJN7yTAl+UMpxFQ4h3Aw1JOf4UWQBOG9Wfxe9 RR+nbwYoE08gzGpQMy6XUJOKTRIrzCjfkDcW193aLbbLvH1tSg S0BRnc9yi03sAfEv9O7L/kFq39/gsugWuAD7KI49bfXbmvFnxy SvOsA4y+CmiUs5oWytfzQf/5V66kHJrXZ7hoWm/ec X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:65486 Archived-At: Hi, the following question was raised at: http://stackoverflow.com/questions/12809610/replace-regexp-in-string-with-lookahead-behind I'd like to replace all occurrences of \w \w with \w\\\w in a string, where the \w parts stay the same before and after the replacement, e.g. [.A foobar] [.B baz] should result in [.A\\foobar] [.B\\baz] ;;;;;;;;;; this might be solved in buffer by (while (re-search-forward "\\_<\\w+\\_>" nil t 1) (replace-match (concat "\\\\\\\\" (match-string-no-properties 0) ))) Also would expect a respective form working with replace-regexp-in-string (setq mystring "[.A foobar] [.B baz]") (replace-regexp-in-string "\\_<\\w+\\_>" (concat "\\\\" (match-string-no-properties 0) ) mystring) but it fails. When commenting "(match-string 0 str)" as follows it subr.el it works (setq matches (cons (replace-match (if (stringp rep) rep (funcall rep ;; (match-string 0 str) )) fixedcase literal str subexp) Which has some plausibility: when receiving a user-specified function, there must not be that argument. Maybe have a look, Best, Andreas