splitting words with brackets

Justin Azoff justin.azoff at gmail.com
Wed Jul 26 16:23:33 EDT 2006


faulkner wrote:
> er,
> ...|\[[^\]]*\]|...
> ^_^

That's why it is nice to use re.VERBOSE:

def splitup(s):
    return re.findall('''
        \( [^\)]* \)  |
        \[ [^\]]* \]  |
        \S+
        ''', s, re.VERBOSE)

Much less error prone this way

-- 
- Justin




More information about the Python-list mailing list