Python Regular Expression

Reply

Join Date: Nov 2007
Posts: 1
Reputation: cyberdon is an unknown quantity at this point 
Solved Threads: 0
cyberdon cyberdon is offline Offline
Newbie Poster

Python Regular Expression

 
0
  #1
Nov 2nd, 2007
I need to find a regular expression in Python. My text string is:

2007-10-12,163.01,167.28,161.80,167.25

I want to extract only the last part: 167.25 (end of line part)

I tried using
regex="(?=[,].+?(?=[\\n]))"
but it did not work. What will be the answer?

Thanks!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,202
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 342
woooee woooee is online now Online
Nearly a Posting Virtuoso

Re: Python Regular Expression

 
1
  #2
Nov 2nd, 2007
Use string.split() instead and split on the commas. Python has a csv module (comma separated variables), but it looks like that would be overkill here.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1813 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC