regexp in string replaced

This commit is contained in:
Willem van den Ende
2023-04-12 23:04:21 +02:00
parent 99aa736759
commit d5c4201e88
+3 -4
View File
@@ -5,7 +5,7 @@
(interactive) (interactive)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "hours ago" nil t) (while (re-search-forward (rx (one-or-more (category digit))) nil t)
(replace-match "")))) (replace-match ""))))
@@ -13,11 +13,10 @@
(ert-deftest test-chat-remove-hours-ago () (ert-deftest test-chat-remove-hours-ago ()
(should (string= (should (string=
(with-temp-buffer (with-temp-buffer
(insert "marcevers\n17 hours ago\n sentence 1\n") (insert "17")
(goto-char (point-min)) (goto-char (point-min))
(chat-remove-hours-ago) (chat-remove-hours-ago)
(buffer-string)) (buffer-string))
"marcevers\n17 \n sentence 1\n" "")))
)))
(ert 'test-chat-remove-hours-ago ) (ert 'test-chat-remove-hours-ago )