all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Question about string-match and match-string
Date: Wed, 17 Jul 2013 10:55:02 +0200	[thread overview]
Message-ID: <20130717085502.GD16899@kuru.dyndns-at-home.com> (raw)
In-Reply-To: <87sizdbmo2.fsf@gmx.us>

Hi Rasmus,

On Wed, Jul 17, 2013 at 10:44:45AM +0200, Rasmus wrote:
> Suvayu Ali <fatkasuvayu+linux@gmail.com> 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.



  reply	other threads:[~2013-07-17  8:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17  8:17 Question about string-match and match-string Suvayu Ali
2013-07-17  8:35 ` Suvayu Ali
2013-07-17  8:44   ` Rasmus
2013-07-17  8:55     ` Suvayu Ali [this message]
2013-07-18  8:00     ` Julien Cubizolles
2013-07-18  8:33       ` Rasmus
2013-07-20 15:26         ` Julien Cubizolles
2013-07-20 22:25           ` Rasmus
2013-07-21  0:41             ` Rasmus
2013-07-21  8:15               ` Julien Cubizolles
2013-07-17  8:53 ` Nicolas Richard
2013-07-17 10:02   ` Suvayu Ali

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130717085502.GD16899@kuru.dyndns-at-home.com \
    --to=fatkasuvayu+linux@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.