Finding Upper-case characters in regexps, unicode friendly. (oh, bugger)

Tim Chase python.list at tim.thechases.com
Wed May 24 22:46:08 CEST 2006


Sorry...I somehow missed the key *uppercase* bit of that, and 
somehow got it in my head that you just wanted unicode letters, 
not numbers.  Please pardon the brain-blink.  I can't find 
anything in Python's regexp docs that do what you want.  Vim's 
regexp engine has a "uppercase characters" and "lowercase 
characters" atoms, but it seems there's no counterpart to them in 
Python.  Thus, you may have to take a combined attack of 
regexps+isupper().

Using isupper() has some peculiar side-effects in that it only 
checks uppercase-able characters, so

 >>> "1A".isupper()
True

which may or may not be what you wanted.  The previously 
shot-from-the-hip regexp stuff will help you filter out any 
non-alphabetic unicode characters, which can then be passed in 
turn to isupper()

-tkc







More information about the Python-list mailing list