mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Fix RE in to_custom_re of text.rs
Match every single (potentially escaped) character of the string, so they can be escaped properly.
This commit is contained in:
parent
8c02c6e205
commit
91873d68eb
1 changed files with 1 additions and 2 deletions
|
@ -313,9 +313,8 @@ pub(crate) fn to_re(txt: &str) -> Cow<str> {
|
|||
|
||||
/// Convert Anki style to RegEx using the provided wildcard.
|
||||
pub(crate) fn to_custom_re<'a>(txt: &'a str, wildcard: &str) -> Cow<'a, str> {
|
||||
// escape sequences and unescaped special characters which need conversion
|
||||
lazy_static! {
|
||||
static ref RE: Regex = Regex::new(r"\\.|[*_]").unwrap();
|
||||
static ref RE: Regex = Regex::new(r"\\?.").unwrap();
|
||||
}
|
||||
RE.replace_all(&txt, |caps: &Captures| {
|
||||
let s = &caps[0];
|
||||
|
|
Loading…
Reference in a new issue