match hours ago with line

This commit is contained in:
Willem van den Ende
2023-04-13 08:20:09 +02:00
parent 3506f61f7f
commit 49dd5dfc48
+5 -4
View File
@@ -5,15 +5,15 @@
(interactive) (interactive)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (rx (one-or-more (category digit))) nil t) (while (re-search-forward "[0-9]+ hours ago" nil t)
(replace-match "dada")))) (replace-match ""))))
(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 "17") (insert "17 hours ago")
(goto-char (point-min)) (goto-char (point-min))
(chat-remove-hours-ago) (chat-remove-hours-ago)
(buffer-string)) (buffer-string))
@@ -21,7 +21,8 @@
(ert-deftest test-replace-hours-ago-regexp-in-string () (ert-deftest test-replace-hours-ago-regexp-in-string ()
(should (string= (should (string=
(replace-regexp-in-string "[0-9]+ hours ago" "" "11 hours ago") (replace-regexp-in-string "[0-9]+ hours ago" "" "space 11 hours ago")
""))) "")))
(ert 'test-replace-regexp-in-string ) (ert 'test-replace-regexp-in-string )
;;(ert 'test-chat-remove-hours-ago )