Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Howto parse a string using a char in python

Reply
Thread Tools

Re: Howto parse a string using a char in python

 
 
Tim Chase
Guest
Posts: n/a
 
      02-15-2013
On 2013-02-15 18:04, Steve Goodwin wrote:
> Hi,
>
> 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?


With just a single character, it sounds like you want something like

whole = "123456:789"
parts = whole.split(':') # or .split(':', 1)
interesting = parts[0]

No custom function needed.

-tkc



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Howto parse a string using a char in python Mark Lawrence Python 0 02-15-2013 11:20 PM
Re: Howto parse a string using a char in python David Robinow Python 0 02-15-2013 11:19 PM
Re: Howto parse a string using a char in python John Gordon Python 0 02-15-2013 11:11 PM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM



Advertisments