bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] Improve regexp that matched on empty strings


From: Antoine Kalmbach
Subject: [COMMITTED] Improve regexp that matched on empty strings
Date: Thu, 12 Nov 2020 17:58:29 +0200

* rec-mode.el (rec-field-value-re): Improve regexp to not match on
the empty string. The surrounding group was zero-or-more and each
subgroup was zero-or-more, this would have matched on the empty
string.
---
 rec-mode.el | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/rec-mode.el b/rec-mode.el
index 0decb99..fb6dacb 100644
--- a/rec-mode.el
+++ b/rec-mode.el
@@ -126,15 +126,7 @@ The default is t."
   "Regexp matching a field name.")
 
 (defvar rec-field-value-re
-  (let ((ret-re "\n\\+ ?")
-        (esc-ret-re "\\\\\n"))
-    (concat
-     "\\("
-     "\\(" ret-re "\\)*"
-     "\\(" esc-ret-re "\\)*"
-     "\\(" "\\\\[^\n]" "\\)*"
-     "[^\\\n]*"
-     "\\)*"))
+  "\\(?:\n\\+ ?\\|\\\\\n\\|\\\\.\\|[^\n\\]\\)*"
   "Regexp matching a field value.")
 
 (defvar rec-type-re
-- 
2.24.3 (Apple Git-128)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]