On Sat, Oct 20, 2012 at 5:14 PM, contro opinion <contropin...@gmail.com> wrote:
> the pattern `re.compile(".(?#nyh2p){0,1}")`  , make me confused,
> can you explain how it  can match the first letter of every word?

It doesn't.

>>> pattern = re.compile(".(?#nyh2p){0,1}")
>>> pattern.findall("a test of capitalizing")
['a', ' ', 't', 'e', 's', 't', ' ', 'o', 'f', ' ', 'c', 'a', 'p', 'i',
't', 'a', 'l', 'i', 'z', 'i', 'n', 'g', '']

The regex is just convolution.  The solution actually works by calling
str.title().  The fact that it calls it 23 times instead of once is
further convolution.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to