last day (15 days later) » 

mag
mag
20:08
hey
mag
mag
So the server I work on has a vouch system
where you can give someone a vouch by tagging them in a specific room and then writing what the vouch is for
I want to write a regex that matches when someone tags someone but doesn't write what the vouch is for
the bot sees discord mentions as <@3242938402492490>
<@3294283028423020348230> aug life <- don't match
<@3423424924029042309403> <- match
<@2309909923043940240290> au <- match
<@2304234284ß284203484> aug influence <- don't match
<@23482034394102391223> rem <- match
this is my test case list
OK, so am I understanding correctly that the number must be a specific number of characters long?
mag
mag
I found `
<@!*&*[0-9]+>` to match the mention itself, but what I need is match the whole string if and only if 1. there's a mention in the string, 2. the mention is followed up by less then n non-whitespace characters
the number is arbitrary
discord ID's can go from 8 digits all the way to 13 or 14
basically I want to match all strings where there is a mention (contained in <@ and > with a number in between) and the non-whitespace text that is not the mention is less then n (say, 4) characters long
You're going to have to define what n is (the actual number of characters permitted to follow the mention.
.... and you did
mag
mag
20:15
I think I need a negative lookahead for that but honestly I'm in over my head for my meager regex skills
How are you using the regex? Is it only a test (i.e. generating only match/not match), or are you using it to get sub portions of the text and/or perform a replacement on the text?
mag
mag
It's a test
Is each line in your examples to be separately considered the entire string which is being tested?
mag
mag
if there's a match the message gets removed and the user gets a PM
yes
each line is the whole string
@mag Your test cases all have more than 14 digits.
mag
mag
20:20
yes, it should only count the chars that are not part of the mention
actually let me get real id's as test cases
<@535849415869726766> +1 non cold <- No match
<@580829651228688389> +1 <- match
<@108635192519823360> aug life <- no match
<@292356812316082176> rem <- match
actually looking at it closer I can live with people with legacy accounts not getting matched so we can assume the ID's are always that long
@mag This regex allows for an unlimited number of ! and & characters after the @, but only both when the order is that any ! are before the &. Is that really what you're wanting? A more typical format would be that there is permitted to be a single ! or a single & character. What exactly are you looking for there?
mag
mag
It might be scuffed or I might have found it wrong
we're using that one to part-match mentions
@mag We can easily specify a range for the number of digits, or permit any number. My concern would be that you might want to reject something like:
<@1>
up to a certain minimum number of digits. You'd mentioned 8 digits as a minimum.
mag
mag
These messages are all coming from the bot
it's guaranteed to have a valid mention otherwise it won't get checked
A few possibilities:
<@!*&*\d{8,}>(?=.{0,4}$) ⠀⠀⠀⠀⠀regex101
<@!*&*\d+>(?=.{0,4}$) ⠀⠀⠀⠀⠀⠀⠀regex101
<@[!&]*\d{8,}>(?=.{0,4}$) ⠀⠀⠀⠀regex101
<@[!&]?\d{8,}>(?=.{0,4}$) ⠀⠀⠀⠀regex101
mag
mag
20:37
all of these work :o
that's amazing
thank you so much, i've been pulling my hair out for a while over this
np. I'm glad I was able to help.

last day (15 days later) »