|
From: | Emanuel Berg |
Subject: | Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. |
Date: | Tue, 28 Sep 2021 03:32:25 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hongyi Zhao wrote: >> Her you go: >> >> (defun inc-all (&optional beg end) >> (interactive (when (use-region-p) >> (list (region-beginning) (region-end)) )) >> (let ((bg (or beg (point-min))) >> (ed (or end (point-max))) ) >> (save-mark-and-excursion >> (goto-char bg) >> (while (re-search-forward "[[:digit:]]\\{2\\}" ed t) >> (replace-match >> (format "%d" (1+ (string-to-number (match-string 0)))) ))))) > > Again, must the above code depend on vertical bars/lines in > the data? No, as it searches for data matching this regular expression "[[:digit:]]\\{2\\}" which doesn't include any vertical lines. -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |