We call this "intentional programming". It's when you program something and expect it to do what your intentions were and not what you programmed it to do.
I feel like "isDigit" should perform the same byte range check as the regex, without the overhead of a regex engine. Or maybe it's a horribly inefficient implementation idk
No it definetly would haha Regex has to compile and even pre-compiled it would not be as efficent I don't unless you need to load a very big specific digit.
I remember when we added sonarqube scans to our repo and it started flagging all of our regexes as potential deadlocks as a dangerous regex without a timeout with the right input can iterate over a string indefinitely. That opened my eyes how scary it is.
💡 Suggestion: compile this regex in a constant variable before using it
and then when you click it it will say
💡 Suggestion: instead of compiling this regex, use the regex code generator to generate a method that does what this regex does, polluting the method list of your class
Yes yes, you are so cool, we are all very impressed. I'm so impressed I would clap, but we're online, so best I can do is give a clapping emoji, to show just how very impressed I am.
Even if you don't know about that, you CAN do inequality checks. Testing if a character >= '0' and <= '9' is sufficient even if you're worried that your code may end up running on an EBCDIC system.
Logically I understand that a spam filter should not tell a spammer that they've been considered spam, but the doing absolutely nothing itches at something.
7
u/Bomaruto Oct 13 '26
I think you wrote it for a terrible joke.
130
u/DogmaticParadigm87 Oct 13 '26
So Bob sails through, and Agent47 is spam. Bold strategy for a contact form.
218
u/keatonatron Oct 13 '26
What is "name"? And why does it having 2+ numbers mean it's spam?
70
u/Ethameiz Oct 13 '26
There is IsDigit method for char
72
u/acd124 Oct 13 '26
Regardless of the horribly verbose digit check, I hate that it says your message has been sent when no attempt has been made when the if fails
10
u/The_Weeaboo_Nextdoor Oct 13 '26
Impressive, I would consider .IsDigit and Regex to be a little bit lower on the knowledge totem pole than async methods and lambdas.
19
u/Pim08UO Oct 13 '26
My email since my primary school is name[4digits]. I must be a spammer 🤷
2
u/svenissimo Oct 15 '26
I worked at a big company that liked to use first.last@company for emails.
There was a glitch and they couldn’t give me mine despite not being used and the system added -199 on my last name.
Only time I never got a single piece of junk mail in 10years.
1
u/Childermass13 Oct 13 '26
Amazing! I have the same combination on my luggage!
-3
u/tatstytastycakes Oct 13 '26
wait are you using namespace std? shame on you.