Tokenize a string or split on steroids
Artur Skura
arturs at iidea.pl
Sat Mar 9 06:54:04 EST 2002
Fernando Rodríguez wrote:
>
> I need to tokenize a string using several separator characters, not just one
> as split().
>
> For example, I want a function that returns ['one', 'two'] when given the
> string '{one}{two}' .
Normaly you would use the re module, but in this case...
>>> import string
>>> a="{one}{two}{three}{four}"
>>> string.split(a[1:len(a)-1],'}{')
['one', 'two', 'three', 'four']
;)
Regards,
Artur
--
http://www.wolneprogramy.org
More information about the Python-list
mailing list