Live data from Hacker News

Stop avoiding regular expressions damn it

bradt.ca

51–55 of 55 posts

Re: Stop avoiding regular expressions damn it

#51

More concise? Sometimes. Slower? Always. BenchmarkRegexp 500000 5136 ns/op BenchmarkStrings 10000000 173 ns/op http://play.golang.org/p/YT29Ao-tOt

Using Golang as an example of real world regex performance is borderline dishonest. Their regex engine is notoriously unoptimized and is not intended to be a strong point of the language.

It's not "unoptimized", it has a different design[1] than other language implementations, resulting in different performance characteristics.

[1] http://swtch.com/~rsc/regexp/regexp1.html

Re: Stop avoiding regular expressions damn it

#52
post #44
post #41

OT: Where from come this seemingly odd and new habit of spacing inside parentheses? I always write "(a, b)", mostly because it is closer to English (or other languages) typography, and it seem to have good readability, plus it is, I believe, the standard in most languages. So why write "( a, b )"? By the way, if some like spacing that much, and if the reason is to have a better mouse-selectability, then I humbly prop…

It's WordPress' PHP Coding Standards: http://make.wordpress.org/core/handbook/coding-standards/php...

Ok. Is there any rationale behind it?

Re: Stop avoiding regular expressions damn it

#53

The core criticism of regular expressions is legitimately directed at intermediate programmers who know enough to be dangerous, but is sometimes inappropriately cargo-culted by beginner programmers who use it as an excuse not to learn regular expressions. The fact is that despite pithy slogans, there is a sweet spot where a regular expression does the job of matching a string in a clearer fashion than anything else.…

As with many things, I find the sweet spot changes depending on my knowledge and familiarity with the concept.

Re: Stop avoiding regular expressions damn it

#54

Earlier quoted context omitted.

Using Golang as an example of real world regex performance is borderline dishonest. Their regex engine is notoriously unoptimized and is not intended to be a strong point of the language.

It's not "unoptimized", it has a different design[1] than other language implementations, resulting in different performance characteristics. [1] http://swtch.com/~rsc/regexp/regexp1.html

Not just a different design, a different set of features. For example, no backreferences.

Re: Stop avoiding regular expressions damn it

#55
post #16

Does anybody know of a good perl of python library that will use a regex (with constraints on the repetition operators) and generate an exhaustive list of matching strings (instead of generating a random list)? I think this would be helpful in many cases in getting people to understand how regexes work. I've seen lots of cases where toolsets designed to help people build regexes end up with them confused when their r…

https://github.com/ferno/greenery

cool, looks like the strings() method in lego.py might work
Post reply on HN