[lug] REGEX DEVELOPMENT TOOL

Anthony Foiani tkil at scrye.com
Tue May 14 20:20:11 MDT 2013


stimits at comcast.net writes:

> gawk (GNU version of awk)
>
> Perl has lots of power there, but awk is the king of regex text
> parsing. Maybe emperor.

Hey now.  :)

It might be that I never put the time into it, but I always felt that
the implicit programming paradigm (pattern -> action) of gawk was
overly constraining.

If nothing else, perl can operate in an awk-like mode via command-line
switches (-n -a), so I generally find Perl to be a superset of awk
functionality -- and if I can learn just one language, then why learn
two?

(Yes, if you do installing or other low-level work on various systems,
you can't be guaranteed that Perl exists -- but at that point, you're
unlikely to have GNU awk, either, just plain awk.  And more and more
critical components depend on higher-level interpreters such as perl
or python, e.g., yum.)

Also, perl regexes (and the built-in language support for them) seem
more powerful than those offered even by GNU awk.  If you have
specific counterexamples, I'd be curious to see them.

(For the most part, you can replace "perl" with "python" above,
although python intentionally leaves out some of the "convenience"
features; a part of its philosophy is to be more explicit about most
things.)

Finally, I found that the rules for quoting often became a disaster,
especially if you're concerned about whitespace or newlines, or
control chars, etc.  (Among other reasons, this is why I use generally
only use bash to automate command-line tasks.)

Anyway.  I suspect that the OP has bigger problem than which regex
implementation to use.

t.




More information about the LUG mailing list