[Top][All Lists]

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

Re: string-match bug?

From: Kevin Rodgers
Subject: Re: string-match bug?
Date: Thu, 10 Dec 2009 21:37:41 -0700
User-agent: Thunderbird (Macintosh/20090812)

Andreas Politz wrote:
address@hidden writes:

On Thu, Dec 10, 2009 at 12:34:45AM -0500, Stefan Monnier wrote:
Actually, it has an infinite number of empty strings at position 0
-- and at every position.
Good, thank you.  I never took the time to count them, so I always
wondered whether there really were enough of them to count as "an
infinite number".  I'm glad it's settled.
Far from it! the more interesting question: countable? /me tries in vain
to hide from Cantor's ghost)

-- tomás

Counting them is easy with the greedy operator.

(and (string-match "\\(\\)*" "")
     (match-end 0))

This proofs, empty strings don't exist.

It proves that (a) 0 or more empty strings match the empty string and
(b) the match ends at the end of the empty string (which having length
0, has start position equal to end position equal to 0 i.e. the returned

Here's how to count the number of of times the empty string matches any
string S at position N:

(let ((match-count 0))
  (while (string-match "\\(\\)" S N)
    (setq match-count (1+ match-count)
          N (match-end 0)))

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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