Search for some regex to return the position of the last numeric digit of a string
$str = '1h 43 dw1r2 ow';
$str = '24 h382';
$str = '2342645634';
$str = 'Hello 48 and good3 58 see you';
This happens, but I'm looking for the fastest way to do this (e.g. regex?)
function funcGetLastDigitPos($str){
$arrB = str_split($str);
for($k = count($arrB); $k >= 0; $k--){
$value = $arrB[$k];
$isNumber = is_numeric($value);
if($isNumber) {
return $k;
break;
}
}
}
source
share