Oh boy... I didn't read you question very well... Here is the PHP version. (untested)
$re = /^A.*Z$/; //set up reg exp to start with an uppercase A and end with an uppercase Z and take anything and everything in between
$mystring = "Ad3f24fj-@%(}lZ"; //string to replace
$mynewstring = str_replace($re, "yourreplacement", $mystring) //replace mystring with "yourreplacement"
NOTE: if that doesn't work, let me know, and I'll get you a tested version... right now I'm in a hurry.