From a3a1f49be108c4dca747de821dcdfb66ca2656ff Mon Sep 17 00:00:00 2001 From: Soren Bjornstad Date: Fri, 28 Aug 2020 15:59:31 -0500 Subject: [PATCH] fix unanchored regex in bulk tag add routine Previously, it was not possible to add a substring of an existing tag. For example, with the tag "foobar", you could not add the tag "foo", "bar" or "oob". Because the match was unanchored, the regex checking whether the tag already existed determined that the tag was present when it was not. --- rslib/src/tags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rslib/src/tags.rs b/rslib/src/tags.rs index f1ef9e306..b5e439476 100644 --- a/rslib/src/tags.rs +++ b/rslib/src/tags.rs @@ -152,7 +152,7 @@ impl Collection { let matcher = regex::RegexSet::new( tags.iter() .map(|s| regex::escape(s)) - .map(|s| format!("(?i){}", s)), + .map(|s| format!("(?i)^{}$", s)), ) .map_err(|_| AnkiError::invalid_input("invalid regex"))?;