New answers tagged

2 votes
Accepted

How to add numbers to all lines matching a certain regex?

There are two go-to options for inserting counters: Keyboard macros. See C-hig (emacs)Keyboard Macro Counter Regexp replacement. See C-hig (emacs)Regexp Replace: ‘\#’ refers to the count of ...
phils's user avatar
  • 48.9k
1 vote

Is the '$' (end of line anchor) somehow concurrent with the '\n' (newline)? Please explain these results

$ is matched only when it's used at the end of the regexp, or at the boundary of a grouping or alternative construct. See (info "(elisp) Regexp Special") or Regexp-Special for more ...
rpluim's user avatar
  • 4,645
1 vote

How to find a newline with a regular expression in query-replace-regexp?

OK, this has been driving me nuts every time I've run into it for over a year now and I finally sat down and figured out what is going on... Unfortunately I don't have a fix---only the actual ...
kspurgin's user avatar
0 votes

replace nth-match of a regexp in a string

(setq toto "a 100 b 200 c 300") (setq bar (replace-regexp-in-string "\\(\\([^0-9]+\\)\\([0-9]+\\)\\)\\{2\\}" "foo" ; Replacement ...
Drew's user avatar
  • 75.8k

Top 50 recent answers are included