Elisp: Case Sensitivity (case-fold-search)
case-fold-search
Case sensitivity for search is controlled by the variable case-fold-search
- case-fold-search
-
Variable. Control case-sensitivity for functions that do text search, including commands that take a Emacs Regular Expression.
- Value of t means smart. That is, if search term contain Capital letters, the search is case-sensitive, otherwise no.
- nil means search is case-sensitive.
- By default, the value is t.
Example of case-fold-search true:
dragon
matches {dragon, Dragon, DRAGON, draGON}Dragon
matches only Dragon.
the following functions are effected:
search-forward
re-search-forward
string-match
replace-regexp-in-string
- not
skip-chars-forward
Change Case Sensitivity in Emacs Lisp Code
In elisp code, set case-fold-search like this:
(let ((case-fold-search nil)) (re-search-forward "ABC") ;; other code here )
Case Sensitivity in Replacement, Text Replace Functions
replace-match
function has a option for it.
Emacs: Case Sensitivity in Text Search
Elisp, Regex in Lisp Code
- Elisp: Regular Expression
- Elisp: Regex Functions
- Emacs: Regular Expression Syntax
- Elisp: Regex Backslash in Lisp Code
- Elisp: Case Sensitivity (case-fold-search)
- Elisp: Find Replace Text in Buffer
- Elisp: Match Data (Regex Result)
- Elisp: Unicode Escape Sequence
- Elisp: Convert Regex to Lisp Regex String
- Elisp: How to Test Regex
- Elisp: Regex in Readable Syntax, Package Rx
- Elisp: Regex Named Character Class and Syntax Table
- Emacs Regex vs Regex in Python, JavaScript, Java