From: Kurtis Rader <krader@skepticism.us>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Bart Schaefer <schaefer@brasslantern.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: backreferences
Date: Thu, 15 Oct 2015 21:27:01 -0700 [thread overview]
Message-ID: <CABx2=D8-YiBxgAKTYPC2LgX4z=b-rEm0K8-x6rwrmRCrHk=SNQ@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3Q5OL807aE9eAw+jp2ueHFO7MPswYeqU0+n0ZUnG5JqgQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]
On Thu, Oct 15, 2015 at 9:11 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
>
> As a sidenote, (^foo)* is always useless to write, since (^foo) will
> expand to the empty string, and then the * will consume anything else.
> A useful way to think of (^foo) is a * that will exclude any matches
> that don't match the pattern foo.
As a recovering Perl addict I cannot +1 this comment enough. Regular
expressions are highly addictive and dangerous. But as Mikael points out it
is extremely easy to write a regexp that is worse than worthless. Google
"regular expression negative lookahead".
Also, Google "now you have two problems". You'll find numerous articles
talking about Jamie Zawinski's observation:
"Some people, when confronted with a problem, think "I know, I'll use
regular expressions." Now they have two problems."
I wholeheartedly agree with that sentiment. Notwithstanding the fact I
still employ regular expressions every single day. The important thing
being that I avoid them outside of ad-hoc interactive searches unless I
have expended considerable thought about their correctness and failure
modes if handed malformed input.
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
next prev parent reply other threads:[~2015-10-16 4:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-15 18:28 backreferences Ray Andrews
2015-10-15 23:16 ` backreferences Bart Schaefer
2015-10-16 1:16 ` backreferences Ray Andrews
2015-10-16 2:30 ` backreferences Bart Schaefer
2015-10-16 4:11 ` backreferences Mikael Magnusson
2015-10-16 4:27 ` Kurtis Rader [this message]
2015-10-16 5:42 ` backreferences Ray Andrews
2015-10-16 5:05 ` backreferences Bart Schaefer
2015-10-16 5:28 ` backreferences Bart Schaefer
2015-10-16 5:46 ` backreferences Ray Andrews
2015-10-16 11:14 ` backreferences Peter Stephenson
2015-10-16 5:36 ` backreferences Ray Andrews
2015-10-16 12:35 ` backreferences Bart Schaefer
2015-10-16 16:37 ` backreferences Ray Andrews
2015-10-17 3:33 ` backreferences Bart Schaefer
2015-10-17 5:16 ` backreferences Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABx2=D8-YiBxgAKTYPC2LgX4z=b-rEm0K8-x6rwrmRCrHk=SNQ@mail.gmail.com' \
--to=krader@skepticism.us \
--cc=mikachu@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).