[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `compare-strings' style question

From: Kevin Rodgers
Subject: Re: `compare-strings' style question
Date: Fri, 20 Nov 2009 03:34:51 -0700
User-agent: Thunderbird (Macintosh/20090812)

address@hidden wrote:
On Thu, Nov 19, 2009 at 08:08:59PM -0700, Kevin Rodgers wrote:

(when (string-match (concat "^" (regexp-quote foo)) bar)

Oops, that should be:

(when (let ((case-fold-search nil))
        (string-match (concat "^" (regexp-quote foo)) bar))

Thanks -- but I was trying to avoid conjuring up the whole regexp
machinery for this task. I admit that this looks less confusing, though.

Perhaps you could enlighten us with some performance measurements?

Another contender:

(let ((foo-len (length foo))
      (bar-len (length bar)))
  (cond ((> bar-len foo-len)
         (equal foo (substring bar 0 (1- foo-len))))
        ((= bar-len foo-len)
         (equal foo bar))
        (t nil)))

Kevin Rodgers
Denver, Colorado, USA

reply via email to

[Prev in Thread] Current Thread [Next in Thread]