[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regexps and strings once again
From: |
Yuri Khan |
Subject: |
Re: Regexps and strings once again |
Date: |
Mon, 15 Sep 2014 08:38:04 +0700 |
On Mon, Sep 15, 2014 at 6:27 AM, Lars Magne Ingebrigtsen <address@hidden> 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"))
- Re: Regexps and strings once again, (continued)
Re: Regexps and strings once again, Lars Magne Ingebrigtsen, 2014/09/15
Re: Regexps and strings once again,
Yuri Khan <=