all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Martin Usbach <auto51@hushmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: A search function that skip some characters
Date: Tue, 06 Dec 2011 16:11:40 -0500	[thread overview]
Message-ID: <jwvvcptcsuw.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <loom.20111206T195347-613@post.gmane.org> (Martin Usbach's message of "Tue, 6 Dec 2011 19:03:48 +0000 (UTC)")

> how can I implement a search function that skip some character (like
> these  characters { '.', ',' , '2'}).  So if I search "text" the
> function should not  only find  "text" but also "tex.t", "t.e,xt.2.",
> "te2xt", "te,,,x.2.t" and so on.

I don't think Emacs has any special support for that.

> Is it too difficult?

I guess it depends on the specifics and on your motivation
and expertise.  You can do

    (re-search-forward (mapconcat (lambda (c) (regexp-quote (string c)))
                                  "text" "[.,2]*"))

which may work, but if "text" is long and/or includes occurrences of
",", "." or "2", this approach may fail miserably.  Also if you need
"text" to be a regular expression, then it gets more interesting.

So if that's not good enough, you'll probably have to do the search "by
hand" without using Emacs's builtin search functionality.


        Stefan



  parent reply	other threads:[~2011-12-06 21:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 19:03 A search function that skip some characters Martin Usbach
2011-12-06 19:33 ` Tekk
2011-12-06 21:11 ` Stefan Monnier [this message]
2011-12-09 20:29   ` martin-u
2011-12-10 16:20     ` Drew Adams
2011-12-11 14:47       ` martin-u

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=jwvvcptcsuw.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=auto51@hushmail.com \
    --cc=emacs-devel@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.