[Python-ideas] Experiment: Adding "re" to string objects.

Georg Brandl g.brandl at gmx.net
Sun Jul 19 09:07:34 CEST 2009


Nick Coghlan schrieb:

> However, the idea of adding more convenience classes to the re module
> may still have some merit. In particular, when checking against multiple
> regexes, being able to do something like the following might be helpful:
> 
> m = re.Matcher(s)
> if m.match(r'whatever(.*)'):
>       print m.group(1)
> elif m.match(r'something (.*) else(.*)'):
>       print m.group(2)

That one looks very useful, and will prevent more proposals of new syntax
along the lines of "if rex.match(...) as m" :)

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.




More information about the Python-ideas mailing list