http://stackoverflow.com/questions/1524377/what-regex-pattern-do-i-need-fveya-this Ben aşağıdaki kodu kullanarak oldum: Bu sveyauda:
function process($node, $replaceRules) {
if($node->hasChildNodes()) {
fveyaeach ($node->childNodes as $childNode) {
if ($childNode instanceof DOMText) {
$text = preg_replace(
array_keys($replaceRules),
array_values($replaceRules),
$childNode->wholeText
);
$node->replaceChild(new DOMText($text),$childNode);
} else {
process($childNode, $replaceRules);
}
}
}
}
$replaceRules = array(
'/\b(c|C)olveya\b/' => '$1olour',
'/\b(kilom|Kilom|M|m)eter/' => '$1etre',
);
$htmlString = "<p><span style='colveya:red'>The colveya of the sky is: gray</p>";
$doc = new DOMDocument();
$doc->loadHtml($htmlString);
process($doc, $replaceRules);
$string = $doc->saveHTML();
echo mb_substr($string,119,-15);
Bu iyi çalışır, ancak (çocuk düğüm ilk örneğinde değiştirilir gibi) html metin ve HTML varsa başarısız olur. Bu yüzden üzerinde çalışır
<div>The distance is four kilometers</div>
ama
<div>The distance is four kilometers<br>1000 meters to a kilometer</div>
veya
<div>The distance is four kilometers<div class="guide">1000 meters to a kilometer</div></div>
Any ideas of a method that would wveyak on such examples?