two ideoms at one blow: line-reading and regexp-matching
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Feb 21 05:34:22 EST 2002
"Jason Orendorff" <jason at jorendorff.com> wrote in
news:mailman.1014233014.12475.python-list at python.org:
> Gustavo Cordova wrote:
>> >>> class WrapRX:
>> ... [...]
>
> This is standard in Python 2.2.
>
> >>> import re
> >>> rx_vowels = re.compile(r"[aeiou]+", re.S)
> >>> some_string = "This is a beautiful string."
> >>> for match in rx_vowels.finditer(some_string):
> ... print "Found vowel: %r" % match.group(0)
> ...
>
Pity it isn't documented. Neither is the scanner method.
I have reported this on sourceforge.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list