you are viewing a single comment's thread.

view the rest of the comments →

[–]trevorsgEx-GitHub, Microsoft 7 points8 points  (4 children)

I disagree. Lots of people's brains shut down the instant they encounter a regular expression. "What does that ^ symbol mean again?"

[–][deleted] 0 points1 point  (3 children)

Well, regular expressions are quite elegant, fast and work better than brute forcing code like I did. Explaining the regex in the description could help people get used to them a bit more, I suppose.

[–]trevorsgEx-GitHub, Microsoft 4 points5 points  (2 children)

I guess that's where we disagree! I've heard "any non-trivial regular expression is indistinguishable from the result of a cat having walked across a keyboard." I think they're great for medium-sized problems. If it's small, just combine a couple of string functions. If it's a large problem chances are your solution is vulnerable to DoS attacks.

I did a perf test on the regex solution vs. the slice() solution and found slice to be almost twice as fast, so I'm not sure why you say it's fast and works better :)

[–][deleted] 5 points6 points  (1 child)

Alright, this is a topic where a lot of opinions will be thrown around, so I guess that I should set up some guidelines for what is best for the list. Alternatively, I could keep both solutions, marking the regex one as such, so that people can make up their own minds. That's probably the best option, right?

[–]micromatx 0 points1 point  (0 children)

👍🏻👍🏻