From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: Troubles in Regular Expression Paradise Date: 14 May 2014 02:56:28 GMT Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1400036427 12470 80.91.229.3 (14 May 2014 03:00:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 May 2014 03:00:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 14 05:00:19 2014 Return-path: Envelope-to: geh-help-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 1WkPQZ-00088Q-E4 for geh-help-gnu-emacs@m.gmane.org; Wed, 14 May 2014 05:00:19 +0200 Original-Received: from localhost ([::1]:48984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkPQY-0003Gj-Ui for geh-help-gnu-emacs@m.gmane.org; Tue, 13 May 2014 23:00:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Original-X-Trace: individual.net G4UbhrP/T7989daNN6eoJwx83poO24iteEU4DdSH4cRnzmw+Os Cancel-Lock: sha1:m+OgbXXdjlNa3TJ9wbT5w7+yNIQ= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/pre1.0.0-18 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:205370 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:97637 Archived-At: Len Blanks wrote: > (defun now-playing (xml-file) > ;; (interactive "FFile: ") > (with-temp-buffer > (insert-file-contents xml-file) > (goto-char 1) > (when (re-search-forward (concat "<!\\[CDATA\\[\\([^\\]+\\)\\]>" > "[\0-\377[:nonascii:]]*" > "" > "[\0-\377[:nonascii:]]*" > "") nil t) > (concat "\\2" > (if (string= (downcase (substring "\\2" -2 -1)) "s") "'" "'s") > " \\1 from the CD \\3")))) > > (message (now-playing "/tmp/now_playing.xml")) ;; test now-playing > > > The regular expression was built and tested using re-build and it works well in matching > including the groupings \\( ... \\), which re-build colours quite nicely. But I seem to have done > something really foolish since referencing \\1, \\2 and \\3 fail, so they don't seem to be > properly set by the groupings in the re. > > The function returns "\2's \1 from the CD \3". > > I'm sure the problem is something foolish, but I would really like to know what i did. You can only use such substitution operators in functions that are aware of them. Normal string-handling functions are not, you'll need something like match-string. -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)