diff --git a/src/data/bot_data.rs b/src/data/bot_data.rs index f6a7272..75b9c61 100644 --- a/src/data/bot_data.rs +++ b/src/data/bot_data.rs @@ -21,7 +21,32 @@ lazy_static! { temp }; - // https://regex101.com/r/aX8vec/5 - pub(crate) static ref EMOJIS_AND_EMBEDS_REGEX: Regex = Regex::new(r"(?(:)([a-zA-Z0-9_]+)(:))|(?(\[)([a-zA-Z0-9_]+)(\])\([^()]*\))").unwrap(); + /// # 2 groups + /// + /// *(matched via bitwise or `|`)* + /// + /// 1. emoji + /// - `:UTF-8:` + /// - Exceptions for the `UTF-8` group: + /// - `:` & `` at both ends + /// 2. embed_emoji + /// - `[UTF-8]()` + /// - Exceptions for the `UTF-8` group: + /// - `` at both ends + /// - `[` at the start + /// - `]` at the end + /// + /// --- + /// + /// + pub(crate) static ref EMOJIS_AND_EMBEDS_REGEX: Regex = Regex::new( + concat!( + "(?", + r"(:)([[^:\s]&&\u0000-\u{10FFFF}&&[^:\s]]+)(:)", + ")|(?", + r"(\[)([[^\[\s]&&\u0000-\u{10FFFF}&&[^\]\s]]+)(\])\([^()]*\)", + ")" + ) + ).unwrap(); }