POV-Ray : Newsgroups : povray.off-topic : Other people dislike regexes too : Re: Other people dislike regexes too Server Time
29 Jul 2024 02:30:23 EDT (-0400)
  Re: Other people dislike regexes too  
From: Warp
Date: 16 Jul 2012 07:48:14
Message: <5003ff7e@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> I don't like regular expressions. Or rather, I don't like the mangled 
> ASCII pea-soup typically used to /represent/ regexes.

That complaint is mostly irrelevant. regexes are excellent for their
most common use, which is to match extremely simple patterns.

"hello" is a regex. It might not look like it, but it is. And that's the
beauty of it. If you use that for example as a search pattern, you will
find all occurrences of those five consecutive characters.

The absolute beauty of it is that there's *no* extraneous syntax *at all*
to perform such a simple match. If you were to separate the syntax into
"commands and arguments", you would only be making the pattern needlessly
complicated and more laborious to write.

But how does that differ from a trivial matching that simply searches for
those consecutive characters and that's it? Well, you can refine the pattern
by adding a few additional key characters to it, to make it perform a more
elaborate search, and in the vast majority of cases it does not become
needlessly complicated or long.

For example, suppose you wanted to search for either "hello" or "Hello".
You would write the pattern as "[Hh]ello".

You would have to be really pedantic if you were to argue that's complicated
and difficult to understand. However, imagine that you were to separate that
into "commands and arguments", how much more complicated and lengthy the
pattern would become.

You can argue against regexes by giving examples of really long and
complicated patterns, but then you would be complaining about extreme
fringe cases, not about *the most common* usage for them, for which they
are just superb.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.