Elisp: How to Test Regex
One simple way to test regex is to create a file with the following content:
(re-search-forward "yourRegex") big text to search here
or
(let ((case-fold-search nil)) (re-search-forward "\\.jpg")) ;; cat.jpg
save the file as test.el, reopen it, so it opens in emacs lisp mode so you have syntax coloring.
Then, put your cursor to the right of the closing parenthesis, then Alt+x eval-last-sexp.
If your regex matches, it'll move cursor to the last char of the matched text.
If you get a lisp error saying search failed, then your regex didn't match.
If you get a lisp syntax error, then you probably screwed up on the backslashs.
emacs and elisp regex
- Emacs: Regular Expression
- Emacs: List Matching Lines
- Emacs: Regular Expression Syntax
- Emacs: Regex Backslash in Command Prompt
- Emacs: Case Sensitivity in Text Search Commands
- Emacs: Insert Tab or Newline
- Emacs: Wildcards vs Regular Expression
- Elisp: Regular Expression
- Elisp: Regex Functions
- 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: Regular Expression in Lisp Syntax, Rx (Package)
- Elisp: Regex Named Character Class and Syntax Table
- Emacs Regex vs Regex in Python, JavaScript, Java