help with regex matching multiple %e

Discussion in 'Python' started by mafunk@nmsu.edu, Mar 3, 2011.

  1. Guest

    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
    , Mar 3, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee
    Replies:
    1
    Views:
    926
    Ilias Lazaridis
    Sep 22, 2006
  2. Xah Lee
    Replies:
    8
    Views:
    454
    Ilias Lazaridis
    Sep 26, 2006
  3. Xah Lee
    Replies:
    2
    Views:
    209
    Xah Lee
    Sep 25, 2006
  4. Bobby Chamness
    Replies:
    2
    Views:
    211
    Xicheng Jia
    May 3, 2007
  5. Replies:
    2
    Views:
    381
Loading...

Share This Page