Alice Wei wrote:

  I have two lines here as follows:

1      -0.123701962557954E+03       0.460967618024691E+02
-0.123547659000000E+03       0.462591090000000E+02

What I am trying to do here is to only have 

1      -0.123701962557954E+03       0.460967618024691E+02 be the output so I can do further processing with it, however, with the code I have in the following, I have both lines in the output. Here is the code:

    $file = "test.txt";
    $fp = fopen($file, "r");
    $lines = file($file);

foreach($lines as $line_num => $line)
if (preg_match("/([^0-9]+\s+)(\-?\d+\.?\d+(\+?E?\d+)?){2}/", $line))

echo $line;

Could anyone please tell me that even when I specify that the line has to start with [^0-9]+\s with one occurrence, why I still get -0.123547659000000E+03       0.462591090000000E+02?

Thanks a lot for your help.


Express yourself with gadgets on Windows Live Spaces
[^0-9] means not a digital....
^[0-9] is the right way..

Laruence's Signature

Baidu惠 新宸 xinchen.hui | SYS | (+8610)82602112-7974 | Hi:laruence

Reply via email to