
Stop writing Regular Expressions – Express them with Verbal Expressions - adamstac
http://thechangelog.com/stop-writing-regular-expressions-express-them-with-verbal-expressions/
======
antichaos
Stop writing URLs as strings. Express them with VerbalResourceLocator:

    
    
      var vrl = VRL().
        schema("https").
        tld("com").
        sld("ycombinator").
        subdomain("news").
        path("/item").
        query({"id": "6164276"});
    
    

Seriously though, Verbal Expression is a great way to turn terse regexps into
un-reusable verbiage that barely improves readability.

~~~
rtpg
Speak for yourself, this is a lot clearer for me. I'm used to navigating
grammars, but I can't deal with regex (way too terse). Especially when I'm not
just matching, but I want to extract info. Some verbosity can go a long way to
making things clearer.

Don't know if this is the solution I'm looking for though

~~~
gojomo
If the terse run-together-ness of usual regexes is unclear, you may also want
to look into 'freespace' formatting... which lets you insert insignificant
whitespace to break the regex into logical groups/lines, and even add inline
comments:

[http://www.regular-expressions.info/freespacing.html](http://www.regular-
expressions.info/freespacing.html)

------
gyepi
I had never heard of this before. The stated goal is to simplify difficult
regular expressions, but the examples seem to be more complicated than the
corresponding regexes. Maybe I'm just old school.

I'm not sure that someone who relies on this would be able to debug the
resulting generated regex when something doesn't work as expected.

~~~
kcorbitt
I agree that for someone who already has the skills to reason with regexes
this has little to offer. But I'm not ready to count the idea out yet -- it's
easy to underestimate the length to which people will go to avoid being forced
to learn a new way to think. Easy string matching without regexes would have
been extremely appealing to my just-starting-programming self.

------
cleaver
I'm always a bit wary of posts that tell me to "Stop doing X". I'm also pretty
comfortable with regular expressions. They take you outside of the procedural
comfort zone, but are a valuable tool that will pay off to learn.

Still, it's worth a shot trying to create a tool like this. What I don't get
is how they would handle subexpressions.

~~~
stphnclysmth
Looking at the wiki, I don't think it does handle them. I reckon that if jehna
when to the trouble of making this, he knows of at least one use case, even if
it's his own. I appreciate that he's shared his work. That said, from my own
experience, by the time a regular expression becomes difficult for me to
parse, there are subexpressions, negative lookbehinds, and other less
comprehensible regex features that this library doesn't seem to support.

------
keithgabryelski
when you pretend you aren't using regular expressions, then you have two
problems.

------
eurleif
pyparsing
([http://pyparsing.wikispaces.com/](http://pyparsing.wikispaces.com/)) is more
object-oriented and composable, and it can parse recursive grammars.

~~~
eru
And of course there's also Parsec ([http://research.microsoft.com/en-
us/um/people/daan/download/...](http://research.microsoft.com/en-
us/um/people/daan/download/parsec/parsec.html)) for Haskell.

~~~
FreakLegion
My first thought was that "Verbal Expressions" are simply parser combinators,
which of course can do things that individual regular expressions can't do.
From the examples though it looks like this is just translating to regular
expressions under the hood, which would make it considerably less powerful
than Parsec and other parser combinator libs.

------
grkovalev
What is news? it's LINQ just for string

------
DavidSJ
Looks like cl-ppcre.

