Improve Regex for Discord
Hi,
I want to start this off by saying there are a few posts about Regex in discord, but they have not received the attention they need, either due to most people not using it, not knowing what it does, or something else of the sort.
I don't know a lot about code at all, but what I do know about Regex is that it's a very useful, special kind of coding language that is used to filter out forms of text. Discord Regex allows you to do things like make only slash command channels, allow certain types of letters and much more (while this is also capable with bots, it would be far nicer to not have to rely on third party sources to implement things like this).
I'm making this post to ask for improved Regex support. As seen by a post by another user who is far more informed about Regex than me, “Currently discord uses the native Rust language engine to handle regexes in the auto-mod, however, the regexes provided natively in rust are far from complete”.
Currently in discord, Regex does not support any forms of lookarounds, which is especially useful when you don't want to allow any type of post that doesn't have a certain piece of text, there is a low character limit that stops users from creating workarounds with the limited Regex available, and far more functions that are missing. Take for example a regex like this: (?:Episode|Ep|Ep\.|Chapter|Ch|Ch\.)\s\d+\s\|\|(.*?)\|\|
This makes it so that you can only say things like “Chapter 1 ||message||” (or variations of chapter and number). However without support for negative lookaheads, it doesn't allow this and the most you can do is match for this format of text (which will only block it). So instead, after reaching out to someone more knowledgeable, he made a preliminary workaround, that he was going to expand with some complex code, the regex looked like this:
(?si)^(?:(?:[^ce]|c(?:(?:[^h]|$)|h[^a.\s]|ha(?:[^p]|$)|hap[^t\s]|hapt(?:[^e]|$)|hapt[^e]|hapte(?:[^r]|$)|hapter\S)|e(?:(?:[^p]|$)|p[^.i\s]|pi(?:$|[^s])|pis(?:[^o]|$)|piso(?:[^d]|$)|pisod(?:[^e]|$)|pisode\S)).*$|(?:chapter|chap|ch|ch\.|episode|ep|ep\.)(?:$|\s)(?:$|\s*(?:(?:$|[^\d\s]|\d(?:[^\d\s]|\d(?:[^\d\s]|\d[^\d\s]))).*$|(?:\d{1,4}(?:$|\s(?:\s*(?:\|?(?:[^|\s].*)?|\|\|[^|]*\|?(?:[^|]+\|)*(?:\|\.+)?)$))|\s.*$|\d{5,}.*$))))
Then an error occurred stating that it was too long.
While it's a great step for Discord to implement Regex into automod, at the current state, Regex is very limited and most of what it can do can already be done by the normal automod filtering. If we want Regex to have any large practical uses in Discord, I believe its imperative that we can find a way to increase its useability. While I don't know much about code, I believe that any performance lost from implementing this WILL be better to improve overall server security and server customization (Another post states, "There is a way in Rust to access the missing regex functions according to this documentation page: https://docs.rs/fancy-regex/latest/fancy_regex/").
Please consider this. Thanks.
TL;DR: Regex, a form of code used to detect more specific things in Discord automod has limited capability, and should support more advanced stuff
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
0 Kommentare