It may not be appropriate depending on the context the regular expression is being used, but I'll offer the following suggestion as an alternate strategy for case-insensitive matching: There is no need to make the regular expression itself case insensitive- if you can normalize the matched string to be case-insensitive. You can achieve an effectively case-insensitive search by normalizing the case of the string to match the case of your regular expression. For example, demonstrating with string-match-p
:
(let* ((my/string "Foo Bar"))
(string-match-p "foo" (downcase my/string)))
;; Returns 0 (indicating a match at the start of the string)
case-fold-search
. Would you elaborate? I triedM-x customize-variable RET case-fold-search
; I set it tonil
. But, this still seems to be ignoring case:M-x search-forward-regexp RET ^[^^I]+^I[a-z]
. Meanwhile, since almost eight years have passed, is there now a way to make an individual emacs regexp be case insensitive? – Zarah