[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A search function that skip some characters
From: |
Stefan Monnier |
Subject: |
Re: A search function that skip some characters |
Date: |
Tue, 06 Dec 2011 16:11:40 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
> 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