Forum Webscript.Ru
Программирование => PHP => Тема начата: AlieN от 16 Мая 2002, 15:46:30
-
Вот есть такая строчка:
Австралийский доллар 1 17.0858 0.5468 0.6062 5/16/02
Обрабатываю его вот так:
if(ereg(" (.*)([[:space:]]+)([0-9]{1,})([[:space:]]+)([0-9]{1,}\\.[0-9]{1,})([[:space:]]+)([0-9]{1,}\\.[0-9]{1,})([[:space:]]+)([0-9]{1,}\\.[0-9]{1,})([[:space:]]{2})([0-9]{1,2})/([0-9]{1,2})/([0-9]{1,2})",$data1[$i],$regs))
{
# print_r($regs);
$regs[1]=trim($regs[1]);
print "$regs[0]-----------------------
$regs[1] $regs[3] $regs[5] $regs[7] $regs[9] ---$regs[11] 10 $regs[10] 12 $regs[12] 13 $regs[13]
--------
";
}
}
В чём проблема(пхп 4.2.0 ): регулярка не показыват дату
хотя как шаблон для егера($regs[0]) её показывает...
В чём беда
При print_($regs) видно что массив состоит из 10 элементов а должен из 13
-
В общем всё получилось но только на перловой регулярке:
if(preg_match("/(.*)(\\s+)([0-9]{1,})(\\s+)([0-9]{1,}\\.[0-9]{1,})(\\s+)([0-9]{1,}\\.[0-9]{1,})(\\s+)([0-9]{1,}\\.[0-9]{1,})(\\s+)([0-9]{1,2})\\/([0-9]{1,2})\\/([0-9]{1,2})/",$data1[$i],$regs))
-
Интересно почему пхп-шная не правильно работает
-
http://www.php.net/manual/en/function.ereg.php
Note: Up to (and including) PHP 4.1.0 $regs will be filled with exactly ten elements, even though more or fewer than ten parenthesized substrings may actually have matched. This has no effect on ereg()\'s ability to match more substrings. If no matches are found, $regs will not be altered by ereg().
-
н-да.....
а в 4.2.хх кол-во элементов расширено?
-
имхо, нет.