all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Regexps and strings once again
Date: Mon, 15 Sep 2014 08:38:04 +0700	[thread overview]
Message-ID: <CAP_d_8VqxReEouT-H3iF1j1bu7bgvUMxekS5mGdysG8WXNHLiA@mail.gmail.com> (raw)
In-Reply-To: <m3lhplixzc.fsf@stories.gnus.org>

On Mon, Sep 15, 2014 at 6:27 AM, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:

> I wrote the function as taking a regexp.  And I find what I'm doing
> wrong 90% of the time when using it is that I expect an exact match, but
> instead I'm getting all matching nodes.

> 1) New Special Syntax
> (dom-by-id dom #/I (can)?haz new syntax/)

> 2) Cheat; i.e., introduce a convention
> (dom-by-id dom (regexp "I \\(couldn't\\)?haz new syntax"))

3) Adopt a convention that matches are literal by default; for regexp
matching, start and end the pattern with a slash.

(dom-by-id dom "/Some *regex+/"))
(dom-by-id dom "Some* literal|string")

4) Mark literal patterns: have a function that turns a string into a
regex, by quoting every metacharacter.

(dom-by-id dom "Some *regex+"))
(dom-by-id dom (literal "Some* literal|string"))

5) Allow the pattern to be an array or list of literal strings. For a
single literal string, use a singleton array/list.

(dom-by-id dom "Some *regex+"))
(dom-by-id dom ["Some* literal|string"])
(dom-by-id dom '("Some* literal|string"))



  parent reply	other threads:[~2014-09-15  1:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-14 23:27 Regexps and strings once again Lars Magne Ingebrigtsen
2014-09-15  0:50 ` Daniel Colascione
2014-09-15  2:14   ` Stefan Monnier
2014-09-15  3:41     ` Daniel Colascione
2014-09-15 12:52       ` Stefan Monnier
2014-09-15 10:04     ` Lars Magne Ingebrigtsen
2014-09-15 10:26       ` Andreas Schwab
2014-09-15 10:33         ` Lars Magne Ingebrigtsen
2014-09-15 12:56       ` Stefan Monnier
2014-09-15  6:39   ` Lars Magne Ingebrigtsen
2014-09-15  7:08     ` Daniel Colascione
2014-09-15  1:38 ` Yuri Khan [this message]
2014-09-15  9:22   ` Andreas Schwab
2014-09-15 10:12     ` Eric Abrahamsen
2014-09-15 10:22       ` Eric Abrahamsen

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=CAP_d_8VqxReEouT-H3iF1j1bu7bgvUMxekS5mGdysG8WXNHLiA@mail.gmail.com \
    --to=yuri.v.khan@gmail.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.