Questions tagged [regular-expressions]

is for patterns specifying search or replace strings. Also known as `regex` or `regexp`, the patterns describe strings to match when searching or replacing. Emacs provides extensive support for `regex` patterns in many commands. Emacs also provides an interactive expression builder for such patterns.

32 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
134 views

LaTeX-aware sentence endings?

Q: how do I define sentence endings to be LaTeX macro-aware? I'd like backward-sentence and forward-sentence to be smarter about LaTeX macros -- particularly \footnote -- when working in LaTeX ...
3
votes
0answers
219 views

Generate a date tree from timestamps in org-mode

Since I was interested in doing my early capture-templates, I was tempted to go with this template below: ("j" "Reference type: Journal" entry (file+headline "~/Dropbox/orgfiles/gtd/ref.org" "...
2
votes
0answers
253 views

How can I use more than 9 regex capture groups in Emacs Lisp?

I have to do a regexp replacement with more than 9 capture groups. How can I do it? Here there is my code (with \\10 and \\12 that they do not work as I expected to): (perform-replace "\\\\href{...
2
votes
0answers
72 views

Upper/lower regexp char classes and current-case-table

I seem to have a problem with [:upper:] [:lower:] and Unicode characters. This test fails: (ert-deftest haskell-upper () (set-buffer (get-buffer-create "*haskell-mode-buffer*")) (insert "Ż") (...
2
votes
0answers
235 views

org-mode smart-quotes (probably prb with the regexps)

I have a problem with org smart-quotes. There are two cases that don't seem to be covered by the standard regexps to identify quotes, namely in the case '" and the case "'. The double quote in both ...
1
vote
0answers
33 views

Simple regexp inside emacs keyboard macro

Newbie question: I'm trying to record a keyboard macro with a simple regexp inside (search-backward-regexp ^[0-9]). This works well when recording the macro, but as soon as I try to execute it, the ...
1
vote
0answers
47 views

How can I split LaTeX inline math from preceeding or following sticked words?

I have this LaTeX code: Lorem $math$ ipsum $math$dolor sit consecteruer adipscing elit, sed do eiusmod tempor incidunt ut labore et dolore magna aliqua. $math$Ut $math$ enim ad minim veniam$math$, ...
1
vote
1answer
25 views

Basic quote regex for font-locking?

I have my own font locking that highlights quotes in comments eg. /* Some comment 'this is quoted' * more 'text in an escaped \` quote'. * Plurals such as Moe's or Joe's should work too. */ ...
1
vote
1answer
33 views

Switch from Dired to Wdired rename file and directory errors when using “-F” or “--classify” ls switch regex help

If you set -F or --classify in the dired-actual-switches then it places a / at the end of directory names and * at the end of executables. When you finish renaming the files, these characters are ...
1
vote
1answer
28 views

Adding a line to the beginning of every function in a (ruby) source code file

Supposed I have a source code file (classes) and some methods in that file. see https://github.com/railstutorial/sample_app_rails_4/blob/master/app/controllers/users_controller.rb I want to add a "...
1
vote
0answers
93 views

Change regex-builder-mode hook to use <C-s>

I recently discovered emacs's "regex-builder" mode and am absolutely loving it. However, there doesn't seem to be an easy way to type in an expression in the "RE-Bulider" buffer and use that ...
1
vote
0answers
29 views

JavaScript regular expressions in re-builder

Is there any package that allows me to input regular expressions following the JavaScript syntax (or even Perl Compatible Reg. Exp.)? I want to have an interactive regular expression builder (like re-...
1
vote
0answers
42 views

How to set ps-end-cut-regexp

I often use ps-print-buffer to print out files, but I don't want the first few lines of the buffer to be printed. Here's the beginning of the buffer: # -*- mode: org; -*- # Last updated: <2017/12/...
1
vote
0answers
148 views

Help Aligning a Pattern with `align-regexp`

How can I use M-x align-regexp to align by // All ; after // All , within [] after // For example: With text: Line 1 ; B // Comment 1 [11, 22] ; Comment 2 [3333, 4] Line 2 C // Comment 3 [3, 55] ...
1
vote
0answers
51 views

using re-search-forward in yas-snippet

I'm trying to develop a new yas-snippet for expanding a common c++ log function I use a lot. The first parameter to the LOG function can be guessed by searching for existing LOG calls in the buffer. ...
1
vote
0answers
69 views

Good way to match symmetric delimiters

I am trying to match $$ resp $ pairs to switch into latex-mode via polymode in a markdown file. $$ is the delimiter for displayed math in this case and $ for inline math. I know that this is not a ...
0
votes
0answers
27 views

Why correct regexp not work in query-replace-regexp?

I want to add 400 in every line where has text "finished". Here text and regexp: as you can see the regexp is correct "finished":\s-*[0-9]+ Nice. Now I use this regexp in query-replace-regexp ...
0
votes
1answer
26 views

How to write regex to change the go keywords color?

I want to change the color which in package import go defer in go-mode ,need a regex..these code only change the pacakge word color (defface my-font-lock-gokeyword-face `((t (:foreground "#...
0
votes
0answers
19 views

Is there is an existing parser for `.gitignore` files?

Is there is an existing parser for .gitignore files? Maybe there is some Elisp package that includes something like this? Ideally, I would like to be able to read a .gitignore file in a given ...
0
votes
1answer
42 views

How to count matches of all buffers?

I am looking for a way to count regexp matches across all buffers. count-matches can count in current buffer. How to count across all buffers?
0
votes
0answers
90 views

Regular expression to match a URL

I am trying to construct a regexp for URLs (for grabbing them out quickly out of a paragraph, region, etc.). I don't need it advanced, but I am having some troubles with it. Here is my attempt, which ...
0
votes
0answers
35 views

C++ Windows Compilation Error/Warning Regexp

I am trying to setup a compile for Emacs on Windows using the CL C++ compiler provided by Windows with Visual Studio 2017. https://imgur.com/a/M80uTWH as can be seen from the above image, however, ...
0
votes
0answers
55 views

Has matches , but re-builder print “No matches”

Emacs 26.1 In scratch buffer I has text KRW-EOS hel-how hello-how-ar h-privet kak-del 123-567 aaa-bbb AAA-BBB AAAA-BBBB AAA-BB AA-BBB A-A AAAAAAAAAA BBBBBB AAA BBB ZZZ-YYY M-x regexp-builder Input ...
0
votes
1answer
55 views

Removing and adding newlines around expressions

I am in the process of formatting a couple of hundred markdown files and am trying to automate that process. I am having two problems, but I guess I can ask two questions ;) Goal I am trying to ...
0
votes
0answers
61 views

Interactively matching beginning of region

Short version: If i bound the scope of a search/replace to a region in the buffer (via the second/third optional argument of search-forward and its derivates), how can i match the beginning of that ...
0
votes
0answers
112 views

Prettify string, find by regex

I want to replace the regular expression `.*` by bolding .* and not displaying the backticks. So I want `elem` to become elem I looked into these questions about how to prettify strings rather than ...
0
votes
0answers
68 views

Why does looking-at ignore the *?

I seem to have some misunderstanding with looking-at. This is my test function : (defun lkat () "interactive looking at" (interactive) (if (looking-at "^\\s-*") (message "yes") (...
0
votes
0answers
49 views

Can you use a regexp in an abbrev definition?

I want to replace words like 1st with 1^{st} and 102nd with 102^{nd} while typing in emacs. Basically I want to replace things that match this: "\([0-9]+\)\(st\|nd\|rd\|th\)" with this \1^{\2} as I ...
0
votes
0answers
165 views

Match regexp group

I am trying to modify org-wikinodes.el to match any org-mode headline (not just camelCase text. So I have replaced the default regular expression with: *\\s-\\(.+\\) This works. But in order to link ...
0
votes
1answer
140 views

Custom search function for dictionary lookup

I have a plain text dictionary in which each headword is matched by ^# \(† \)?headword, How can I make a custom search function that relieves me of typing the whole regex every time I want to look ...
0
votes
1answer
225 views

Left-align org-mode like FoldingText… Regexp?

I posted this question on stackoverflow earlier, but perhaps this is a better place for it? I am looking for a way to left-align text in Org-mode so that the paragraphs line up like in FoldingText. ...
0
votes
0answers
112 views

Need help with a snippet

Can someone help me with this snippet? I found it here # -*- mode: snippet -*- # name: jsdoc comment # key: doc # -- /** * $0 `(save-excursion (let* ((pos-fun (re-search-forward "\\<function\\s-*(...