Partition Recursive
kj
no.email at please.post
Fri Dec 24 00:03:06 EST 2010
In <be6f45b2-5a5a-4461-b5de-000487a46e8f at w2g2000yqb.googlegroups.com> macm <moura.mario at gmail.com> writes:
>url = 'http://docs.python.org/dev/library/stdtypes.html?highlight=partition#str.partition'
>So I want convert to
>myList =
>['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?','highlight','=','partition','#','str','.','partition']
>The reserved char are:
>specialMeaning = ["//",";","/", "?", ":", "@", "=" , "&","#"]
You forgot '.'.
>>> import re # sorry
>>> sp = re.compile('(//?|[;?:@=&#.])')
>>> filter(len, sp.split(url))
['http', ':', '//', 'docs', '.', 'python', '.', 'org', '/', 'dev', '/', 'library', '/', 'stdtypes', '.', 'html', '\
?', 'highlight', '=', 'partition', '#', 'str', '.', 'partition']
~kj
More information about the Python-list
mailing list