function _onlyNumbersDiffer($a, $b)
{
if ($a == $b) {
return false;
}
$pattern = '/([^0-9]*)([0-9]*)([^0-9]*)/';
$aMatchCount = preg_match_all($pattern, $a, $aMatches, PREG_SET_ORDER);
$bMatchCount = preg_match_all($pattern, $b, $bMatches, PREG_SET_ORDER);
if ($aMatchCount != $bMatchCount || $aMatchCount == 0) {
return false;
}
// Check each match. If the 1st and 3rd (text) parts all match
// then only numbers differ in the two supplied strings.
for ($i = 0; $i < count($aMatches); $i++) {
if ($aMatches[$i][1] != $bMatches[$i][1]) {
return false;
}
if ($aMatches[$i][3] != $bMatches[$i][3]) {
return false;
}
}
// No counterexamples were found. Only numbers differ.
return true;
}