[Tutor] python challenges

jfouhy@paradise.net.nz jfouhy at paradise.net.nz
Fri May 6 03:05:27 CEST 2005


Quoting Max Noel <maxnoel_fr at yahoo.fr>:

> (Also, note that however simple they may seem, one can never 
> completely master regular expressions. There are entire books 
> dedicated to the things, and when properly used, they're the most 
> powerful text processing tool available for any language. In other 
> words, try to remember what you'll learn about them: they're very 
> useful.)

At the risk of being pedantic ---

This is not actually true.  There are things you can't do with regular
expressions.  The normal example is bracket counting: If I give you a string
like '(1+(2-4/(3+8)*(5+9)))-(8+1)', can you write me a regex which will produce
matches for only the chucks defined by the brackets?  

(in this case, the answer is this list of substrings: ['(1+(2-4/(3+8)*(5+9)))',
'(2-4/(3+8)*(5+9))', '(3+8)', '(5+9)', '(8+1)'] )

-- 
John.


More information about the Tutor mailing list