From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Suvayu Ali Newsgroups: gmane.emacs.help Subject: Re: Question about string-match and match-string Date: Wed, 17 Jul 2013 10:55:02 +0200 Message-ID: <20130717085502.GD16899@kuru.dyndns-at-home.com> References: <20130717081704.GB16899@kuru.dyndns-at-home.com> <20130717083511.GC16899@kuru.dyndns-at-home.com> <87sizdbmo2.fsf@gmx.us> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1374051364 2902 80.91.229.3 (17 Jul 2013 08:56:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Jul 2013 08:56: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 Wed Jul 17 10:56:06 2013 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 1UzNWn-00076R-FY for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Jul 2013 10:56:05 +0200 Original-Received: from localhost ([::1]:54556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzNWn-000259-5q for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Jul 2013 04:56:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzNVs-0001Im-MJ for help-gnu-emacs@gnu.org; Wed, 17 Jul 2013 04:55:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzNVr-0007rr-L5 for help-gnu-emacs@gnu.org; Wed, 17 Jul 2013 04:55:08 -0400 Original-Received: from mail-we0-x22b.google.com ([2a00:1450:400c:c03::22b]:57578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzNVr-0007rZ-FQ for help-gnu-emacs@gnu.org; Wed, 17 Jul 2013 04:55:07 -0400 Original-Received: by mail-we0-f171.google.com with SMTP id m46so1509903wev.2 for ; Wed, 17 Jul 2013 01:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=PPlSo5vtRumBJD9SdTH39+RZ2dCu3y+EDQeo8a6xkcU=; b=YFfgGribZvaHG5FJjvXqi0WdFgQhuyaH6K6uXyyYid7+woPsvgMsDGoFD6RR75m00U toMUqYJ9rtRDrJ7XIEAoKMqiIc79fl6Mctycb7fQhe5AcCHi8AnC20Y6gaWTj7JbtYPt W3nPr4M04y1jxDRvpPakWXdWB0CWbSDPw2UBWilm0gee2HoXnhrBotbyRiHQvCyiXHiu 2Y80yu2aVBh/o5WyFfT+hZSMVJj4Xeq4CklV7M5za4hRNzenNHICYfMmu6aAbe0SbplP F5/YqKaBrk/QTxKmjgLJbZeCBH2BwAfXtf0NvVIm15aXNZBux7W7z/10jBZJDe1viRc2 WacA== X-Received: by 10.194.179.233 with SMTP id dj9mr4075858wjc.46.1374051306593; Wed, 17 Jul 2013 01:55:06 -0700 (PDT) Original-Received: from kuru.dyndns-at-home.com (sd44012d5.adsl.online.nl. [212.64.18.213]) by mx.google.com with ESMTPSA id fs8sm33464145wib.0.2013.07.17.01.55.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 17 Jul 2013 01:55:05 -0700 (PDT) Content-Disposition: inline In-Reply-To: <87sizdbmo2.fsf@gmx.us> User-Agent: Mutt/1.5.21 (2012-12-30) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22b 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:92199 Archived-At: Hi Rasmus, On Wed, Jul 17, 2013 at 10:44:45AM +0200, Rasmus wrote: > Suvayu Ali writes: > > > On Wed, Jul 17, 2013 at 10:17:04AM +0200, Suvayu Ali wrote: > >> > >> Debugger entered--Lisp error: (args-out-of-range -1 -1) > >> replace-match("" t nil "{" 1) > > > > I forgot to mention, the string above, "{", keeps changing with every > > subsequent evaluation! I tried to extract the sub-expressions with > > match-string with no luck. I get nil! > > > > (let ((test "\\section{Heading{ignoreheading}}\nText\n")) > > (string-match "\\(\\\\\\\\section{.+{ignoreheading}}\\\\n\\)\\(.+\\)" test) > > (match-string 1 test) > > ) > > Are you just trying to implement an ignoreheading filter? > Yes I am! :) > This is what I use. I think Nicolas provided it in a post at some > point but I'm not sure. > > (defun rasmus/org-latex-ignore-heading (headline backend info) > "Strip headline from HEADLINE if it has tag ignoreheading for > certain headlines. `info' is Ignored" > (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii) > (string-match "\\`.*ignoreheading.*\n" > (downcase headline))) > (replace-match "" nil nil headline))) > > (add-to-list 'org-export-filter-headline-functions > 'rasmus/org-latex-ignore-heading) Thanks for the code, I will use it. But I would still like to know what I was doing wrong. -- Suvayu Open source is the future. It sets us free.