brackets content regular expression

Alex_Gaynor alex.gaynor at gmail.com
Fri Oct 31 13:49:13 EDT 2008


On Oct 31, 1:25 pm, netimen <neti... at gmail.com> wrote:
> I have a text containing brackets (or what is the correct term for
> '>'?). I'd like to match text in the uppermost level of brackets.
>
> So, I have sth like: 'aaaa 123 < 1 aaa < t bbb < a <tt  > ff > > 2 >
> bbbbb'. How to match text between the uppermost brackets ( 1 aaa < t
> bbb < a <tt  > ff > > 2 )?
>
> P.S. sorry for my english.

I think this is what you're looking for:

In [11]: re.compile('\<(.*)\>').findall('aaaa 123 < 1 aaa < t bbb < a
<tt  > ff > > 2 > bbbbb')
Out[11]: [' 1 aaa < t bbb < a <tt  > ff > > 2 ']



More information about the Python-list mailing list