I want to replace a character inside a word, so I wrote:
(setq regexp "[ab]") (and (re-search-backward regexp nil t 1) (replace-match "c"))
c as I wish, but I want to set a bound of it.
There is a
BOUND option with
How can I make the match only a word that is under the current cursor?
Thanks for @jackson I can write the function, but still it doesn't work properly.
(setq regexp ".*[ab].*") (defun test-it () (interactive) (save-excursion (save-restriction (narrow-to-region (progn (backward-word) (point)) (progn (forward-word) (point))) (and (re-search-backward regexp) (replace-match "c")))))
Thins function replaces
cd as I expected, but it doesn't replace