RegEx only apply on strings, not on code.
function charCallbackRand($matches1){
$charOne = (int)$matches1[1];
$charTwo = (int)$matches1[2];
return 'rand('.$charOne.','.$charTwo.')';
}
$myword = '__Random_and[22,95]';
$result = preg_replace_callback('/__Random_anm\[(\d+),(\d+)\]/', 'charCallbackRand', $myword);
Your code is way complicated for doing such a simple thing, see Solution 1.