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.
This commit is contained in:
Soren Bjornstad 2020-08-28 15:59:31 -05:00 committed by Soren I. Bjornstad
parent 4662a9fe1a
commit a3a1f49be1

View File

@ -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"))?;