r/badcode • • Oct 06 '21

sql So umm this is from Twitch source code leak . NSFW

Post image
2.9k Upvotes

400 comments sorted by

View all comments

Show parent comments

19

u/Informal_Swordfish89 Oct 06 '21

Even then still... I'd probably choose to use regex.

It's incredibly flexible and allows easy upscaling.

14

u/FistThePooper6969 Oct 06 '21

It would depend on the scale imo as regex is MUCH slower than an efficient string operation.

20

u/frugalerthingsinlife Oct 06 '21

Forget runtime cost. Maintainability of regex would be tough as people come up with clever new names. And not everyone is a regex wizard, but anyone can add a bad word to a bad word list.

A bayesian filter, like they use in spam, would be more all-encompassing.

19

u/Maalus Oct 06 '21

"The plural of regex is regrets" is my motto, nothing good comes from having tons of regexes to check against.

2

u/frugalerthingsinlife Oct 07 '21

Ooh, that's good. That's my motto, too, now.

1

u/DavidRoyman Oct 25 '21

2

u/Maalus Oct 25 '21

No worries my dude, I stole it from someone else as well.

1

u/DavidRoyman Oct 25 '21

I like when a .gif loops so well. Have an upvote!

3

u/Aperture_Executive2 Oct 06 '21

Not always, if your engine is like grep it can do most complex patterns and inputs in under 10 seconds

1

u/_PM_ME_PANGOLINS_ Oct 06 '21

Then you're just hand-coding a particular instance of a regex matcher, which will be many thousands of lines for any serious attempt at this.

Or just use an existing regex engine to compile it for you...

-2

u/[deleted] Oct 06 '21

lmao regex, /r/badcode