Problem splitting a string
Jason Stitt
jason at pengale.com
Sat Oct 15 00:58:06 EDT 2005
On Oct 14, 2005, at 11:52 PM, Anthony Liu wrote:
> I have this simple string:
>
> mystr = 'this_NP is_VL funny_JJ'
>
> I want to split it and give me a list as
>
> ['this', 'NP', 'is', 'VL', 'funny', 'JJ']
>
> 1. I tried mystr.split('_| '), but this gave me:
>
> ['this_NP is_VL funny_JJ']
Try re.split, as in:
import re
re.split('_| ', mystr)
-Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051014/7c3406de/attachment.html>
More information about the Python-list
mailing list