[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp optimization question
From: |
Kevin Rodgers |
Subject: |
Re: elisp optimization question |
Date: |
Thu, 08 May 2008 19:42:07 -0600 |
User-agent: |
Thunderbird 2.0.0.14 (Macintosh/20080421) |
Lennart Borgman (gmail) wrote:
Another way to make it faster would perhaps be to make one regular
expression with regexp-opt and then check the match.
That's a good suggestion, and it led me to look into regexp-opt for the
first time. But how do I get it to capture just the variant part of the
matched strings in "\\( ... \\)" i.e. excluding any common prefix or
suffix?
E.g.
(regexp-opt '("»" "’")) =>
"&#\\(?:\\(?:18\\|821\\)7;\\)"
(regexp-opt '("»" "’") t) =>
"\\(&#\\(?:\\(?:18\\|821\\)7;\\)\\)"
But what I'd like it to return is "&#\\(\\(?:18\\|821\\)7;\\)"
so that (match-string 1) would return just "187" or "8217".
--
Kevin Rodgers
Denver, Colorado, USA