I would like to use a function that processes the matched pattern, using a backreference, like this:   $table[0] = "cat" $table[1] = "dog" Func decode($n) Return $table[$n] EndFunc $string = "Hello this is a &0; and this is a &1;" $decoded = StringRegExpReplace($string, "&(.*?);", decode(\1)) ;<---- Sorry if this was asked before.