Live data from Hacker News

The true power of regular expression

nikic.github.io

1–10 of 20 posts

Re: The true power of regular expression

#2
> But when programmers talk about “regular expressions” they aren’t talking about formal grammars. They are talking about the regular expression derivative which their language implements. And those regex implementations are only very slightly related to the original notion of regularity.

That's why we call those derivatives "Franken-xpressions". They can take exponential time in the worst case. See "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" (http://swtch.com/~rsc/regexp/regexp1.html).

The additional power of Franken-xpressions comes at a cost.

For general purpose parsing, I suggest using a parser combinator library.

Re: The true power of regular expression

#6
The main point against using regular expression for me is that it takes developers that are new to the code (or yourself in a few months) so long to figure out what is happening there, not that they are not powerful. The fact that there is no way to debug them in most environments and no comments does not help.

Re: The true power of regular expression

#7
post #6

The main point against using regular expression for me is that it takes developers that are new to the code (or yourself in a few months) so long to figure out what is happening there, not that they are not powerful. The fact that there is no way to debug them in most environments and no comments does not help.

[deleted]

Re: The true power of regular expression

#8
post #6

The main point against using regular expression for me is that it takes developers that are new to the code (or yourself in a few months) so long to figure out what is happening there, not that they are not powerful. The fact that there is no way to debug them in most environments and no comments does not help.

So, if I understand you correctly, "programmers can't be bothered to write decent documentation, therefore using powerful features is bad (and we should stick to rudimentary tools)"? In other words, clumsy workmen are an argument against using power tools - or am I missing your point entirely?

Re: The true power of regular expression

#10
post #2

> But when programmers talk about “regular expressions” they aren’t talking about formal grammars. They are talking about the regular expression derivative which their language implements. And those regex implementations are only very slightly related to the original notion of regularity. That's why we call those derivatives "Franken-xpressions". They can take exponential time in the worst case. See "Regular Expressi…

[deleted]
Post reply on HN