brackets content regular expression
alex.gaynor at gmail.com
Fri Oct 31 18:49:13 CET 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 : re.compile('\<(.*)\>').findall('aaaa 123 < 1 aaa < t bbb < a
<tt > ff > > 2 > bbbbb')
Out: [' 1 aaa < t bbb < a <tt > ff > > 2 ']
More information about the Python-list