mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Annotate RegEx for invalid-escape check
This commit is contained in:
parent
a16d271eb0
commit
a6628709c5
1 changed files with 9 additions and 1 deletions
|
@ -447,7 +447,15 @@ fn unescape_quotes(s: &str) -> Cow<str> {
|
||||||
fn is_invalid_escape(txt: &str) -> bool {
|
fn is_invalid_escape(txt: &str) -> bool {
|
||||||
// odd number of \s not followed by an escapable character
|
// odd number of \s not followed by an escapable character
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref RE: Regex = Regex::new(r#"(^|[^\\])(\\\\)*\\([^\\":*_()]|$)"#).unwrap();
|
static ref RE: Regex = Regex::new(
|
||||||
|
r#"(?x)
|
||||||
|
(?:^|[^\\]) # not a backslash
|
||||||
|
(?:\\\\)* # even number of backslashes
|
||||||
|
\\ # single backslash
|
||||||
|
(?:[^\\":*_()]|$) # anything but an escapable char
|
||||||
|
"#
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
RE.is_match(txt)
|
RE.is_match(txt)
|
||||||
|
|
Loading…
Reference in a new issue