From 060bad105dc2569fc485adb03b985aa2ab5d367e Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 22 Feb 2022 23:47:09 +0000 Subject: Move new utilities to the util namespace --- botcore/regex.py | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 botcore/regex.py (limited to 'botcore/regex.py') diff --git a/botcore/regex.py b/botcore/regex.py deleted file mode 100644 index 036a5113..00000000 --- a/botcore/regex.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Common regular expressions.""" - -import re - -DISCORD_INVITE = re.compile( - r"(discord([.,]|dot)gg|" # Could be discord.gg/ - r"discord([.,]|dot)com(/|slash)invite|" # or discord.com/invite/ - r"discordapp([.,]|dot)com(/|slash)invite|" # or discordapp.com/invite/ - r"discord([.,]|dot)me|" # or discord.me - r"discord([.,]|dot)li|" # or discord.li - r"discord([.,]|dot)io|" # or discord.io. - r"((?[a-zA-Z0-9\-]+)", # the invite code itself - flags=re.IGNORECASE -) -""" -Regex for discord server invites. - -:meta hide-value: -""" - -FORMATTED_CODE_REGEX = re.compile( - r"(?P(?P```)|``?)" # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block - r"(?(block)(?:(?P[a-z]+)\n)?)" # if we're in a block, match optional language (only letters plus newline) - r"(?:[ \t]*\n)*" # any blank (empty or tabs/spaces only) lines before the code - r"(?P.*?)" # extract all code inside the markup - r"\s*" # any more whitespace before the end of the code markup - r"(?P=delim)", # match the exact same delimiter from the start again - re.DOTALL | re.IGNORECASE # "." also matches newlines, case insensitive -) -""" -Regex for formatted code, using Discord's code blocks. - -:meta hide-value: -""" - -RAW_CODE_REGEX = re.compile( - r"^(?:[ \t]*\n)*" # any blank (empty or tabs/spaces only) lines before the code - r"(?P.*?)" # extract all the rest as code - r"\s*$", # any trailing whitespace until the end of the string - re.DOTALL # "." also matches newlines -) -""" -Regex for raw code, *not* using Discord's code blocks. - -:meta hide-value: -""" -- cgit v1.2.3