On May 7, 2008, at 10:46 AM, Iames Pizzoli wrote:

>                I need a little help from you. Let's say I have this  
> string:
>
> Apples [some text]; oranges [some more text]; bananas [more text];
> etc. etc.
>
>                Now I want the whole string EXCEPT the square  
> brackets and
> what is inside them, i.e.
>
> Apples ; oranges ; bananas ;
>
>                How can I do it? I know I could use the brute force  
> (parsing
> the string char by char), but I'm after a smarter way. TIA

        In Python, it's pretty simple:

import re
txt = "Apples [some text]; oranges [some more text]; bananas [more  
text];"
print re.sub(r"(\[[^\]]+\])", "", txt)

=> Apples ; oranges ; bananas ;

-- Ed Leafe





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to