From: Nikolai Weibull Date: 2004-11-19T04:20:29+09:00 Subject: Re: About Regular Expressions * James Edward Gray II [Nov 18, 2004 19:40]: > > My opinion is this: Regexp's are for CS-heads --those who really > > love programming for its it's own sake. Regexp are about as terse > > and cryptic as one can get, and thus have a steep learning curve. > My experience has been the opposite. > At my wife's company, they spend a significant portion of everyday > importing raw text reports from their database into Excel for various > uses. Some of the reports do not go into Excel well at all. A large > chunk of most employee's day is spent cleaning up these reports, by > hand. (I'm considering one of these reports for a future Ruby Quiz, if > that gives you any idea how wonky they can be.) > When my wife came to me for help and showed me the problem, the > solution turned out to be simple. I helped her download a simple text > editor with Regular Expression search and replace, over the phone. > That evening, I taught her a useful subset of Regular Expression and > together we built and printed a "cheat sheet" she could take to work > with her. Yet, she came to you. Wouldn't it have been great if this kind of thing had been so obvious to anyone that there wasn't a need for a programmer to point it out to someone with a search and replace problem? > My wife is no programmer. She's a slightly above average computer > user. She's great with Excel and can record macros, but she would > never thing of editing one, by way of example. It literally took me > about three hours to get her doing useful things with Regular > Expression. Today, she's the wizard at her company they all come to > for help. She's easily the most productive employee they have, when it > comes to any kind of reporting work. That's great! Hopefully they'll take the time to actually learn what she's teaching them and spread the knowledge themselves. > I'm not trying to imply anything about you or your beliefs. I'm just > saying that some people don't seem to have too much trouble with them. > I know my wife still keeps that cheat sheet right next to her computer. > Perhaps a trick like that would be of some use to you or other folks > who struggle with Regular Expression. The regular expression syntax we are using today is a potpourri of various ideas, extensions, and cruft that's been collected over the years. It was never designed, just as Unix was never designed. Yet, they are both extremely useful. They are, however, not easy to use for anyone unfamiliar with them. Regular expressions stem from mathematical research and therefore most of the notation is very terse. 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). Remember, regular expressions match precisely the regular languages, which are, according to Chomsky, the simplest of languages. Why, then, do they have to be so hard to specify? 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);}