简化**替换正则

This commit is contained in:
yangshangbo
2025-04-15 15:56:05 +08:00
parent d1da1e9bc1
commit 028d7013a8
+1 -4
View File
@@ -74,10 +74,7 @@ fn match_path_with_regex(real_path string, reg_path string) (bool, regex.RE) {
start := time.now() start := time.now()
mut one_more_star_reg := regex.regex_opt(r'\*{2,}') or { panic(err) } mut one_more_star_reg := regex.regex_opt(r'\*{2,}') or { panic(err) }
repl_on_e_more_star_fn := fn (re regex.RE, in_txt string, start int, end int) string { repl_on_e_more_star_fn := fn (re regex.RE, in_txt string, start int, end int) string {
if in_txt.ends_with('*') { return r'[^#\?]+'
return r'([^#\?]/){0,}[^#\?]+'
}
return r'([^#\?]+//){0,}[^#\?]+'
} }
mut replaced_reg_path := reg_path.replace('?', r'\?') mut replaced_reg_path := reg_path.replace('?', r'\?')
replaced_reg_path = replaced_reg_path.replace('+', r'\+') replaced_reg_path = replaced_reg_path.replace('+', r'\+')