4 ms·
Why not just convert numbers like 1 to i or l then check with a manually created bad word list? Would regex be really much faster than checking it against a 10
by DethNinja 5y ago
Why not just convert numbers like 1 to i or l then check with a manually created bad word list?
Would regex be really much faster than checking it against a 1000 or more bad word list?
Also bad word list can easily get updated by moderators as well, I really can’t understand the logic behind using so much regex.
- cbsmith 5y agoA bad words list is a regex. ;-) But note: for the most part this isn't using regexs, and to the extent it does, it seems largely intended to make the maintainers' lives easier by avoiding having to represent (and maintain) all the permutations they are trying to match for. What's sad though is that they're doing many, many passes through the pattern matcher, rather than just building a single big DFA from the whole list of patterns they want to match, which gets traversed in one pass.
- sa46 5y agoCould Postgres convert the function into a DFA using the JIT optimizer (based on LLVM)? That might delve into sufficiently smart compiler territory but recognizing a bunch of OR'ed string matches seems on the easier end of optimization passes.
- cbsmith 5y agoYup, that's definitely sufficiently smart compiler territory. If you want to write an optimization pass that handles that, go for it, but you won't find one already there.
- jakear 5y agoRegEx => DFA conversation can lead to exponential growth in number of states... don't know how big it'd be in this case.