emacs-devel
[Top][All Lists]
Advanced

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

Re: regexp case sensitivity bug


From: Kim F. Storm
Subject: Re: regexp case sensitivity bug
Date: 10 Dec 2002 13:43:15 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Andreas Schwab <address@hidden> writes:

> address@hidden (Kim F. Storm) writes:
> 
> |> Or we can use a completely different approach:
> |> 
> |> (defun isearch-no-upper-case-p (string regexp-flag)
> |>   "..."
> |>   (let ((case-fold-search nil))
> |>     (save-match-data
> |>       (null (string-match 
> |>               (if regexp-flag "\\(^\\|[^\\]\\)[[:upper:]]" "[[:upper:]]")
> |>               string)))))
> 
> That needs to check whether there is an even number of \ before the
> letter, because only then the letter is not part of a special regex
> matcher.

Ouch!  Try this:

(defun isearch-no-upper-case-p (string regexp-flag)
  "..."
  (let ((case-fold-search nil))
    (save-match-data
      (null (string-match 
              (if regexp-flag "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*[[:upper:]]" 
"[[:upper:]]")
              string)))))

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

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