Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Pire does not have any Perlish conditional regexps, lookaheads & backtrackings, greedy/nongreedy matches; neither has it any capturing facilities."

Well that rules out nearly every use case I have for needing a regex in the first place.



I was actually building something very similar to this, though I stopped about six months ago due to time constraints. The goal was to be able to check which of a set of regular expressions matches a given string, and then invoke PCRE or similar to get the subexpression capture. The end result: Django-style regex URL routing against an arbitrary number of expressions, in the same amount of time as routing against a single expression.

Of course, I generally never use any of those features except the capture. (And greedy/nongreedy matching, but that is irrelevant if you're not doing a subexpression capture)


When dealing with very very large datasets, the ability to filter fast is important. So it becomes a 2-stage (actually n-stage...) problem: filter the raw data, and remove the parts that are known irrelevant (alternately include only the 'maybes'), then do the more intensive processing on the smaller resultant data-set. When done in parallel it looks a lot like map-reduce :)


Greedy / non-greedy is one of the main things I use in regexes (well, second to capturing). That sucks. Though if it's non-capturing, I guess it makes sense.

How many people do use regexes for boolean operations? I can only think of an instance or two where I have, aside from regular input validation.


Most uses of non-greedy matching can be replaced with faster, clearer, and more precise inverted character classes, in my experience.


Probably the only use case I can think of, is for "does it match?" tests. Spam detection, like SpamAssassin, might benefit from it.


If that is the case, wouldn't we just use more specialized functions, I forget the boost_regex function for C++, but for PHP we can do strpos() instead strstr() to see simply if a string exists? In that case, I'm guessing the benchmarks would be closer.


Substring location won't tell you if your string is an email, for example.




From the page you linked:

> This regular expression will only validate addresses that have had any comments stripped and replaced with whitespace (this is done by the module).

There is filtering done before the regex is applied.


Yes, good point.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: