According to the documentation of this function, it should be case sensitive. But when I test it out, the result is case insensitive.

My emacs version is 25.3.2.

  • 1
    According to which documentation? C-h f re-search-forward is very clear about this being dependent upon case-fold-search, and I'm confident that the manual does not say any differently.
    – phils
    Commented Oct 14, 2018 at 12:09
  • It is my bad in reading documentation. I also read from ergoemacs.org, but somewhat miss the important information. I confirm that your statement is correct. Commented Oct 14, 2018 at 13:50

2 Answers 2


re-search-forward is case insensitive by default as it depends on (as @phils points out in the comment) case-fold-search. You can toggle case sensitivity with: toggle-case-fold-search The following is from ergoemacs.org:

By default, Emacs regex is not case sensitive unless the pattern contains capital letters. That is, dragon will match “dragon” and “Dragon” and “DRAGON” and “draGON”. But Dragon will match only “Dragon”.

Case sensitivity is controlled by the variable case-fold-search. Alt+x toggle-case-fold-search to toggle it. Remember to toggle it back when you are done. Because case-fold-search is also used by isearch and basically all search or find/replace commands.

Do not use [A-z], because that'll match some punctuation chars too. Use [A-Za-z].


You can toggle case-sensitivity on the fly during Isearch, using M-c. So just C-M-s M-c will turn on case-sensitivity for the duration of the search (assuming it was turned off globally). You can toggle it back and forth as much as you want during the same search, which can be handy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.