Monday, 19 August 2013

Regular expression stripping $ in one string but not another

Regular expression stripping $ in one string but not another

I'm trying to use regular expressions to add php variables into an
external html page so I can email is as html email in phpMailer
the string i'm trying to replace is:
<strong> %temp_pass%% </strong></p><p>
<a
href="http://www.unlimitedtutors.com/forgotpass.php?email=%e%%&p=%myTempPass%%">
my regex is:
$hashTempPass = "$2a$10$";
$temp_pass = "'=$.hel3332lo\/'";
$body = file_get_contents('email/forgot_pass_email.html');
$forgot_pass_email = preg_replace('#[A-Za-z%]name%%#', $name, $body);
$forgot_pass_email = preg_replace('#[0-9A-Za-z$.\/%]e%%#',$e,
$forgot_pass_email);
$forgot_pass_email =
preg_replace('#[0-9A-Za-z.%]temp_pass%%#',$temp_pass,
$forgot_pass_email);
$forgot_pass_email = preg_replace('#[0-9A-Za-z.%]myTempPass%%#',"$2a$10$",
$forgot_pass_email);
The problem is that all of the $ and number symbols are stripped out of
the myTempPass%%, but not from the temp_pass%% - its driving me crazy -
what am i doing wrong? is it to do with the fact that myTempPass is in a
url? how can i get it to include $/. in the replacement?
thanks,
M

No comments:

Post a Comment