Re: [Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Bod Soutar
Steven's answer is probably a lot more robust, but I would use a simple split. mylist = ['hypothetical protein BRAFLDRAFT_208408 [Branchiostoma floridae]\n', 'hypoxia-inducible factor 1-alpha [Mus musculus]\n', 'hypoxia-inducible factor 1-alpha [Gallus gallus]\n' ] for item in mylist: item.spl

Re: [Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Jing Ai
Thank you all for the suggestions! I decided to use Steven's re loop in the end. Joel, what i meant earlier was that the link you sent seems to suggest me to replace some characters in the list and I'm not sure how it would work... On Sun, Dec 29, 2013 at 9:24 PM, Joel Goldstick wrote: > > >

Re: [Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Joel Goldstick
On Sun, Dec 29, 2013 at 9:00 PM, Jing Ai wrote: > Thanks, but I don't think I can get out the string in the brackets by only > replacing other items...(there's too many things to replace and may > interfere with the items within the string). > > > I am not sure what you mean by your previous sen

Re: [Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Steven D'Aprano
On Sun, Dec 29, 2013 at 04:02:01PM -0500, Jing Ai wrote: > Hello, > > I am trying to rewrite some contents on a long list that contains words > within brackets and outside brackets and I'm having trouble extracting the > words within brackets, especially since I have to add the append function > f

Re: [Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Joel Goldstick
On Sun, Dec 29, 2013 at 4:02 PM, Jing Ai wrote: > Hello, > > I am trying to rewrite some contents on a long list that contains words > within brackets and outside brackets and I'm having trouble extracting the > words within brackets, especially since I have to add the append function > for list

[Tutor] Using Regular Expression to extracting string in brackets on a list

2013-12-29 Thread Jing Ai
Hello, I am trying to rewrite some contents on a long list that contains words within brackets and outside brackets and I'm having trouble extracting the words within brackets, especially since I have to add the append function for list as well. Does anyone have any suggestions? Thank you! *An e