From: Nikolai Weibull Date: 2004-11-19T08:30:00+09:00 Subject: Re: About Regular Expressions * Brian Schr�der [Nov 18, 2004 23:50]: > > Mathematicians prefer terseness and so do many programmers, but > > there is no need for terseness in something like regular expressions > > used for search and replace. That's why EMACS and Vim use extended > > versions of BRE not ERE for example (which is a point though as \ is > > a bitch to type). > > Thats the only thing I hate in emacs. I always have to look up the > regular expression syntax, or do some trial-error until I get the > emacs re escapings right. Why don't they simply use the syntax > everyone else uses. Good question. See below. > I do not see, where the emacs syntax is simpler to read/write than > ruby/perl/egrep syntax. It isn't simpler. It is less mathematical if you will. The idea is that most often you want to search for a fixed string and thus /(/ should match '(' and not be a metacharacter for grouping (and capturing if that's required). This makes much more sense in Vi-based editors, as there is only one search command (by default), namely '/'. In EMACS you have a choice of searching for a regular expression and a fixed string, by using different keybindings. Thus, for EMACS, using BRE over ERE is just plain silly (I'm trying to use kind words from now on). Anyway, the main problem with the current state of affairs is that there are so many incompatible regular expression implementations, all with their own quirks and special syntax. The biggest evil-doer in my opinion is Perl5. There's too much going on. They have crammed context-free language matching into regular expressions, while at the same time making them NP-complete. Sure, look-around has its uses, and there's a lot of nice stuff you can do. Is it necessary, though? Hardly. I won't argue this point any further, but the bottom line is that regular expressions have been abused and need some time to recuperate. nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}