Re: scanf style parsing
by Skip Montanaro other posts by this author
Sep 27 2001 4:24PM messages near this date
Re: scanf style parsing
|
Re: scanf style parsing
Tim> It's not usually easy to learn regexps, no matter what your
Tim> background. I come from C/C++ roots (Turbo C++ 3.0) and TRS-80
Tim> BASIC before that, and I certainly had no idea what regex's were
Tim> really for until I looked at Perl.
I think the best way to learn about regular expressions is to use
incremental regular expression searching in Emacs/XEmacs. Just bind C-s and
C-r to isearch-forward-regexp and isearch-backward-regexp. Then, every time
you search you're using re's. Initially you'll just use plain strings, but
eventually start mixing in "." and character classes. Before you know it
"*" and "+" will be your buddies too. Once you start adding "\(", "\|" and
"\)" to your repertoire, you will attain enlightenment. ;-)
You'll generally never cook up complex regular rexpressions using
incremental search because you have no convenient way to correct mistakes
and retry, but you will use all the pieces and build up more complex stuff
when you're programming Perl or Python. Making the leap from Emacs's
old-style re's to POSIX-style re's as Perl and Python use now is fairly
straightforward. Mostly it involves getting rid of backslashes and learning
about {m,n}, \d, \s and other little shortcuts. (I still almost never use
\d. My fingers just type [0-9] automatically.)
maybe-the-best-argument-against-vi-ly, yr's
--
Skip Montanaro (skip@pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Bruce Dawson
Skip Montanaro
George Demmy
Hans-Peter Jansen
Quinn Dunkan
Tim Hammerquist
Ralph Corderoy
Toby Dickenson
Duncan Booth
Aahz Maruch
Aahz Maruch
Aahz Maruch
Stefan Schwarzer
Grant Edwards
Fredrik Lundh
Malcolm Tredinnick
Ralph Corderoy
Tim Hammerquist
Stefan Schwarzer
Greg Ewing
Skip Montanaro
Boyd Roberts
Steve Clift
Bruce Dawson
Tim Hammerquist
Tim Hammerquist
Tim Hammerquist
Skip Montanaro
Andrew Dalke
Fredrik Lundh
Oleg Broytmann
Andrei Kulakov
Duncan Booth
Chris Barker
Tim Hammerquist
Skip Montanaro
Jon Nicoll
Oleg Broytmann
Bruce Dawson
Skip Montanaro
Andrei Kulakov
Richard Jones
Skip Montanaro
Andrew Dalke
|