我是新来的正则表达式,但我没有现在的时间来了解它, 但我需要将eregi(“^ ..?$”,$ file)转换为preg_match(),但是我 don'不知道该怎么做,任何人都可以帮助我吗?将PHP eregi转换为preg_match,我该怎么做?
也给我的工作原理有一点了解也将是 不错的:)
的一段代码:
$fileCount = 0;
while ($file = readdir($dh) and $fileCount < 5){
if (eregi("^..?$", $file)) {
continue;
}
$open = "./xml/".$file;
$xml = domxml_open_file($open);
//we need to pull out all the things from this file that we will need to
//build our links
$root = $xml->root();
$stat_array = $root->get_elements_by_tagname("status");
$status = extractText($stat_array);
$ab_array = $root->get_elements_by_tagname("abstract");
$abstract = extractText($ab_array);
$h_array = $root->get_elements_by_tagname("headline");
$headline = extractText($h_array);
if ($status != "live"){
continue;
}
echo "<tr valign=top><td>";
echo "<a href=\"showArticle.php?file=".$file . "\">".$headline . "</a><br>";
echo $abstract;
echo "</td></tr>";
$fileCount++;
}
您可能需要花时间,也许我们没有任何余地 – RiggsFolly
快速查看Stack会揭示其他人提出的问题,也许这可能有助于http://stackoverflow.com/questions/2501494/how-to-convert-eregi-to-preg-match?rq = 1 – RamRaider
不要等人为你写代码,你最好开始学习正则表达式。这很简单。 – lorond