From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Len Blanks Newsgroups: gmane.emacs.help Subject: Re: Troubles in Regular Expression Paradise Date: Tue, 13 May 2014 22:13:55 -0500 Organization: Socialist Workers Computational Vision and Robotics Collective Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400037285 22931 80.91.229.3 (14 May 2014 03:14:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 May 2014 03:14:45 +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:14:38 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 1WkPeN-0007Kf-GH for geh-help-gnu-emacs@m.gmane.org; Wed, 14 May 2014 05:14:35 +0200 Original-Received: from localhost ([::1]:49023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkPeM-0005MB-SS for geh-help-gnu-emacs@m.gmane.org; Tue, 13 May 2014 23:14:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkPe1-0005Lq-Ta for help-gnu-emacs@gnu.org; Tue, 13 May 2014 23:14:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkPds-0004dD-SV for help-gnu-emacs@gnu.org; Tue, 13 May 2014 23:14:13 -0400 Original-Received: from haruspex.net ([2001:470:0:62::4834:7886]:45918) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1WkPds-0004d5-E6 for help-gnu-emacs@gnu.org; Tue, 13 May 2014 23:14:04 -0400 Original-Received: from localhost ([70.171.94.129]) by haruspex.net for ; Tue, 13 May 2014 20:14:00 -0700 Mail-Copies-To: never X-GPG-Key-ID: C7189399 X-GPG-Fingerprint: 1938 0CB6 C718 9399 X-url: http://www.haruspex.net/ X-Attribution: Len X-Unexpected: The Spanish Inquisition X-Mayan-date: Long count = 13.0.1.7.8; tzolkin = 5 Lamat; haab = 1 Zip X-Now-Playing: \2's \1 from the CD \3 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEVWnI6iOSfcPiGGnji4 t6ZuNSUqLCTwqzY4xBRjAAACeklEQVQ4jV2TQW/bMAyFPdTArqNSpWcRcHzunMxXN1GRa+SW OtsDxHvtFvr7oyy7LcYcAvATH0XqubCXl9/mqMha1NZeXu0SXVF0d4D46wz3FqG0Xbfmy8Je Yozv50lbNK/2+WbXKOxjXU+4Q3NEc+ueTptSYa91jSluxkiVLkWsswm0iBMKAzSAdX0v6rYU qVJ6TDHiFrpYw3YqZ+B/8gmWf2PcsJGf0iL1h4QA4JaSZRKbMMa3CbUDBRqUz+eb5u4aUxhw Ss6DplwRo81gTlkw5BYtKyDnhWhN4DTlkiK+242cKIiadgK6VGFz+j02J+8AHMkksqwvqUvj dACjSSZZKnJc5+bZ67CULCOu+WOzOzVM0gXhOzgRyXR/AgX5/wY+nB5PyvhA7KTEb2Bmte95 VD5VkFP7FTS0UwcBZx2CVzpsoIGP45PpjT5XFPyo9/0tg7at4puSncsIo/fk+8/mJhqntFxM zksfWEEbxQbuwUzGEGlm9ryAOSqsZOHqDEDyGhzAD0vFrPDglJGn0E47p+UQZ9DiYVQo+3Yk Qg7zhHLdI1ZBHijQKFLMhcP9sIB2qngkIh/SnXnoflQJzA8JsOxCngmr3vihexzyHAlwcNQj VqwMFXefIHimZDhleMRq6IYyA7k9uwQceu5rn76Qq3hhAp+kAFDjngf1kT6DLJWADI6HvuKh gFuqaCeRkuasnIAROe1DKtoNBBU0Visot+YJIMsYpBYg3hW7zdNBeoyGezSk/PrhJC8sAwqQ /WnHG5jll677dwHwDcxN4/YbMI6To9c3F5svgOQtibsvqaahBYQHFDN04vXkdgEvAsQgHPra ZOOW9h98UxIFO6KpIwAAAABJRU5ErkJggg== In-Reply-To: (Joost Kremers's message of "14 May 2014 02:56:28 GMT") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (darwin) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:0:62::4834:7886 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:97638 Archived-At: Joost Kremers writes: > 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. Vielen Dank. I'll try that. -- Len Science is supposedly the method by which we stand on the shoulders of those who came before us. In computer science we are all standing on each others' feet. -- G Popek