splitting words with brackets

Qiangning Hong hongqn at gmail.com
Wed Jul 26 16:18:36 EDT 2006


faulkner wrote:
> re.findall('\([^\)]*\)|\[[^\]]*|\S+', s)

sorry i forgot to give a limitation: if a letter is next to a bracket,
they should be considered as one word. i.e.:
"a(b c) d" becomes ["a(b c)", "d"]
because there is no blank between "a" and "(".




More information about the Python-list mailing list