@@ -23,21 +23,28 @@ pub fn get_quote_pairs() -> HashMap<&'static str, &'static str> {
2323 quote_pairs
2424}
2525
26- lazy_static:: lazy_static! {
27- pub static ref PARENS_REGEX : Regex = Regex :: new( r"[\((<{\[](?:[^\)\]}>)]|\\[\)\]}>)])*[\)\]}>)]" ) . unwrap( ) ;
28- pub static ref EMAIL_REGEX : Regex = Regex :: new( r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}" ) . unwrap( ) ;
29- pub static ref NUMBERED_REFERENCE_REGEX : Regex = Regex :: new( r"^(\s*\[\d+])+" ) . unwrap( ) ;
30- pub static ref SPACE_AFTER_SEPARATOR : Regex = Regex :: new( r"^\s+" ) . unwrap( ) ;
31- pub static ref QUOTES_REGEX : Regex = {
32- let quote_pairs = get_quote_pairs( ) ;
33- let patterns: Vec <String > = quote_pairs
34- . iter( )
35- . map( |( left, right) | format!( r"{}(\n|.)*?{}" , regex:: escape( left) , regex:: escape( right) ) )
36- . collect( ) ;
37- let quotes_regex_str = patterns. join( "|" ) ;
38- Regex :: new( & quotes_regex_str) . unwrap( )
39- } ;
40- }
26+ use std:: sync:: LazyLock ;
27+
28+ pub static PARENS_REGEX : LazyLock < Regex > =
29+ LazyLock :: new ( || Regex :: new ( r"[\((<{\[](?:[^\)\]}>)]|\\[\)\]}>)])*[\)\]}>)]" ) . unwrap ( ) ) ;
30+
31+ pub static EMAIL_REGEX : LazyLock < Regex > =
32+ LazyLock :: new ( || Regex :: new ( r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}" ) . unwrap ( ) ) ;
33+
34+ pub static NUMBERED_REFERENCE_REGEX : LazyLock < Regex > =
35+ LazyLock :: new ( || Regex :: new ( r"^(\s*\[\d+])+" ) . unwrap ( ) ) ;
36+
37+ pub static SPACE_AFTER_SEPARATOR : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"^\s+" ) . unwrap ( ) ) ;
38+
39+ pub static QUOTES_REGEX : LazyLock < Regex > = LazyLock :: new ( || {
40+ let quote_pairs = get_quote_pairs ( ) ;
41+ let patterns: Vec < String > = quote_pairs
42+ . iter ( )
43+ . map ( |( left, right) | format ! ( r"{}(\n|.)*?{}" , regex:: escape( left) , regex:: escape( right) ) )
44+ . collect ( ) ;
45+ let quotes_regex_str = patterns. join ( "|" ) ;
46+ Regex :: new ( & quotes_regex_str) . unwrap ( )
47+ } ) ;
4148
4249pub const EXCLAMATION_WORDS : [ & str ; 17 ] = [
4350 "!Xũ" ,
0 commit comments