Re: splitting words with brackets
- From: "Qiangning Hong" <hongqn@xxxxxxxxx>
- Date: 26 Jul 2006 14:15:22 -0700
Tim Chase wrote:
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. :)
Ah, it's exactly what I want! I thought the left and right sides of
"|" are equal, but it is not true. I think I must sleep right now,
lacking of sleep makes me a dull :-p. Thank you and Simon for your
kindly help!
.
- Follow-Ups:
- Re: splitting words with brackets
- From: Tim Chase
- 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
- Re: splitting words with brackets
- From: Tim Chase
- 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):