mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-08-06 12:53:39 +08:00
refactor: 使用 regex 1.13.0 引入的内置 regex! 宏
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
macro_rules! regex {
|
||||
($re:literal $(,)?) => {{
|
||||
static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new();
|
||||
RE.get_or_init(|| regex::Regex::new($re).expect("invalid regex"))
|
||||
}};
|
||||
}
|
||||
use regex::regex;
|
||||
|
||||
pub fn filenamify<S: AsRef<str>>(input: S) -> String {
|
||||
let reserved = regex!("[<>:\"/\\\\|?*\u{0000}-\u{001F}\u{007F}\u{0080}-\u{009F}]+");
|
||||
|
||||
Reference in New Issue
Block a user