30
athlon
2y

There ain’t no feeling like replacing 6 lines of code with 6 characters of Regex.

Comments
  • 8
    Until it’s time to debug it.
  • 2
    How much code does the regex trigger?
  • 4
    I am curious what six lines can be replaced by six characters of regex.
  • 2
    Yeah. That feeling is disgust.
  • 2
  • 2
    Shorter code is not necessary a better code.
  • 3
    Only replacing 500 lines of JS with 20 lines of CSS.
  • 0
    IMO, regular expressions are needed mostly for not thinking about HOW MUCH lines of code it's gonna replace, but rather WHEN there's room for user's customization.

    new RegExp(userProvidedRegExp, "i")

    Also, guys, you'd better off dissing on Perl.
  • 2
    @vintprox: User provided regexps are the easiest way to add a DOS opportunity.
  • 0
    @Oktokolo perhaps, a "user" I'm talking about should be familiar with regular expressions they add, to avoid "Evil Regexp" opportunities. Sort of more aware users. Obviously, we shouldn't give this power to userbase that's not configuring anything. Especially when program covers all required scenarios already.
  • 0
    @vintprox: Doesn't matter how experienced the user is or whether he configures stuff or not. What matters is whether the user is trusted to not be an attacker or controllable by an attacker.

    It is fine to give employees the ability to search by regexp - even if they sometimes degrade performance for others a bit. Granting that power to random people from the Internet might be asking for trouble though - especially, when they know regular expressions...
  • 0
    Regex is kinda like the terminal - at first your instinct is to fear it, then you learn it and it's so useful in editor searches that it ends up sticking
Add Comment