php - Regular expression to match numeric columns -


need regular expression matches numeric columns only. each row of numeric columns may or may not contain decimal point plus minus sing , letter "e". number of white spaces between each column may happen more one. , number of columns not fixed.

representative sample of text parsing.

  #b0 alphanumeric line 26_0000 abc #b1  57 115 550.000000 270.000000  #n 18 #labels x y   else here -16.3252 -11.205718    0 2.61836e-07 110 -16.1728 -10.90549    0 2.61836e-07 87  -16.0228 -10.605516    0 2.61836e-07 50  -15.8728 -10.305796    0 2.61836e-07 31 -15.7229 -10.005822    0 2.61836e-07 49  -15.5727 -9.705594    0 2.51826e-07 4998 -15.4228 -9.40562     0 2.71836e-07 176  alphanumeric  -14.9729 24678   com @ -14.7531    sum = 147364  ave.mon./time = 136117  

i'm little unclear you're asking for, let me @ least point in right direction...

you know this:

\d*(?:\.\d+)* 

matches decimal number. so, extend match negative numbers so:

-?\d*(?:\.\d+)* 

and extend further match numbers have "e-..." @ end, so:

-?\d*(?:\.\d+)*(?:e-\d+)? 

then finally, if want search whole line onle contains numbers this, separated whitespace, use:

^(?:-?\d*(?:\.\d+)*(?:e-\d+)?\s*)*$ 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -