text->getText(); $re = '/\[\s*(-?\d+)\s*\,\s*(-?\d+)\s*\]/'; preg_match_all($re, $text, $matches, PREG_SET_ORDER, 0); foreach ($matches as $match) { $pos = strpos($text, $match[0]); $text = substr_replace($text, mt_rand($match[1], $match[2]), $pos, strlen($match[0])); } return $text; } }