[Tutor] Brain In Vice: Why is this so fun to me?

Alan Gauld alan.gauld at freenet.co.uk
Thu Apr 20 02:25:38 CEST 2006


> I cannot for the life of me figure out a pythonic way (read: using the
> split() builtin) to scan for instances of these characters in such and 
> such
> order and proximity. I know this is what regex is for,

I'm afraid so, it looks like the time has come to import re.

>  I have obtained a copy of "Mastering Regular Expressions"

Good book but probably overkill unless you get really serious

> I would inquire here first for caveats and tips

Build them up gradually, test them at the >>> prompt or using
the tool that comes with Python. Don;t forget the power of building
a negative of what you want and then searching for the inverse.
Finally remember that match() is usually the wrong function to
use - it only searches at the beginning of the string!

And, of course, I have a topic on regex :-)

Good luck!

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld






More information about the Tutor mailing list