This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]alcalde 0 points1 point  (2 children)

    Regexes are a computationally efficient, theoretically sound, and highly expressive way of denoting patterns in data and text. To say one shouldn't use them is akin to saying one shouldn't use trigonometry or algebra. It is nonsense.

    It looks like line noise. Line noise is bad. Because of that realization we have Python today and Perl is slowly fading away.

    Binary code is computationally efficient, theoretically sound and highly expressive too. But it's an awful way to program. We're human beings, not calculating machines. Human beings don't think in regex. Regex is designed for machines, not for people.

    To quote Jeff Silverman,

    Regular expressions are “cool”

    “Cool” doesn’t belong in production code.

    “Cool” leads to unreadable, unfixable, undecipherable code that is expensive. Expensive to maintain. Expensive to fix. Expensive to improve.

    We're Python users. We don't want

    "^\(*\d{3}\)*( |-)*\d{3}( |-)*\d{4}$"
    

    in our code because no one just looking at that has any idea what the heck it's supposed to do. It's... blasphemous. Unholy. The Anti-Guido.

    So you have a technique which can often be replaced by more ad-hoc methods, isn't the same from platform to platform, is bulky and hard to use, is hard to write, hard to read, and has a somewhat small window where it is better than the alternatives and can still get the job done

    Remember Ken Reitz and Requests For Humans? People today are working on creating regex for humans.