Re: splitting words with brackets
- From: Tim Chase <python.list@xxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Jul 2006 16:05:30 -0500
but it can't pass this one: "(a c)b(c d) e" the above regex
gives out ['(a c)b(c', 'd)', 'e'], but the correct one should
be ['(a c)b(c d)', 'e']
Ah...the picture is becoming a little more clear:
>>> r = re.compile(r'(?:\([^\)]*\)|\[[^\]]*\]|\S)+')
>>> r.findall(s)
['(a c)b(c d)', 'e']
It also works on my original test data, and is a cleaner regexp than the original.
The clearer the problem, the clearer the answer. :)
-tkc
.
- Follow-Ups:
- Re: splitting words with brackets
- From: Qiangning Hong
- Re: splitting words with brackets
- References:
- splitting words with brackets
- From: Qiangning Hong
- Re: splitting words with brackets
- From: Tim Chase
- Re: splitting words with brackets
- From: Qiangning Hong
- splitting words with brackets
- Prev by Date: Re: splitting words with brackets
- Next by Date: Re: splitting words with brackets
- Previous by thread: Re: splitting words with brackets
- Next by thread: Re: splitting words with brackets
- Index(es):