Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > help with regex matching multiple %e

Reply
Thread Tools

help with regex matching multiple %e

 
 
mafunk@nmsu.edu
Guest
Posts: n/a
 
      03-03-2011
Hi,

i have a line that looks something like:
2.234e+04 3.456e+02 7.234e+07 1.543e+04: some description

I would like to extract all the numbers. From the python website i got the
following expression for matching what in c is %e (i.e. scientific
format):
(see http://docs.python.org/library/re.html)
[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?
And when i apply the pattern (using extra parenthesis around the whole
expression) it does match the first number in the line.

Is there any way to repeat this pattern to get me all the numbers in the
line?
I though the following might work, but i doesn't:
([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?){numToRepeat)

Or will i have to split the line first, then iterate and the apply the match?

Any help is greatly appreciated.

thanks
matt

 
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
Regex testing and UTF8 awarenes or Regex and numeric pattern matching sln@netherlands.com Perl Misc 2 03-10-2009 03:51 AM
Help with Pattern matching. Matching multiple lines from while reading from a file. Bobby Chamness Perl Misc 2 05-03-2007 06:02 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Python 8 09-26-2006 03:24 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Perl Misc 2 09-25-2006 03:15 AM
String Pattern Matching: regex and Python regex documentation Xah Lee Java 1 09-22-2006 07:11 PM



Advertisments