Howto parse a string using a char in python

John Gordon gordon at
Sat Feb 16 00:11:52 CET 2013

In <511ebf0c$0$21334$9a6e19ea at> "Steve Goodwin" <sgoodwin at> writes:

> I am looking for the python2.7 function(s) to parse a string from a colon 
> character ":"

> Sounds simple enough.

> For example, a string like "123456:789".  I just need the "123456" 
> substring.(left of the :)

> I have looked at regular expressions and string functions, so far no luck. 
> Custom function required?

Use the split() string function.

John Gordon                   A is for Amy, who fell down the stairs
gordon at              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

More information about the Python-list mailing list