On 04/05/11 17:04, Erik Christiansen wrote:
On Wed, May 04, 2011 at 10:00:40AM -0400, Charles Campbell wrote:
There's probably a history of regular expressions somewhere; ed
definitely preceded (the original) vi, and I think sed did, too. Awk
followed in sed's "footsteps", and Perl came after vi. Vim follows
vi's reg-ex (with extensions) handling. Anyway, I don't think the
various programs' reg-ex styles are going to merge because that would
invalidate a lot of scripts, so claiming that "X's style is better
than Y's style" isn't going anywhere. IMHO Vim did it the right way
-- that is, it extended earlier reg-ex handling, not changed it (like
Perl did).
Regex uniformity across unix tools is valuable beyond measure, because
we then don't fumble and stumble unproductively when moving between them.
O'Reilly's "Mastering Regular Expressions" mentions that "POSIX
standardized the workings of over 70 programs, including traditional
regex-wielding tools such as awk, ed, egrep, expr, grep, and sed."
OK, grep defaults to BRE (basic regular expression), while egrep and awk
default to ERE (extended regular expression), but standards don't
preclude all choice. IME, custom extensions may bring benefits, but that
needs to be on a common RE base, if the tool is to deliver greatest
utility, OOTB.
For some time I've intended to check how close vim wanders to posix EREs
when its regexes are prefixed with \v, but for the moment it's good
enough that it mostly works when thinking in EREs. (To whatever extent
vim can be set to be posix compliant, I agree that "Vim did it the right
way".)
Yes, perlisms are "more powerful", but I'd still only use the ERE
capability, where possible, if I ever were to use perl, because that's
the common base.
Erik
I don't really know any other regular expressions than Vim's, because
those are exhaustively documented, in a set of cross-linked helpfiles
which I constantly have at my fingertips.
Sometimes I use regular expressions in less or egrep, and in that case I
try (not too complicated) Vim patterns in the hope that they will be
recognized: they often are, and when they aren't, well, let's try
something else then.
If I were to regularly use some program with a different regexp dialect,
I'd try to find the appropriate documentation, because trial-and-error
may be OK for occasional use, it won't do for serious systematic
programming.
Best regards,
Tony.
--
Honk if you love peace and quiet.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php