Tokenize
Alan Kennedy
alanmk at hotmail.com
Thu Jul 24 15:24:07 EDT 2003
Ken Fettig wrote:
> Does Python have an equivelent to the Java StringTokenizer? If so,
> what is it and how do you implement it?
Is this the kind of thing that you mean?
Python 2.3b1 (#40, Apr 25 2003, 19:06:24)
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "This is a string to be tokenised"
>>> s.split()
['This', 'is', 'a', 'string', 'to', 'be', 'tokenised']
>>> s = "This:is:a:string:to:be:tokenised"
>>> s.split(':')
['This', 'is', 'a', 'string', 'to', 'be', 'tokenised']
>>> s.split(':', 2)
['This', 'is', 'a:string:to:be:tokenised']
>>>
Or maybe you have something more specific in mind?
--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
More information about the Python-list
mailing list