perezf Posted July 2, 2008 Share Posted July 2, 2008 How do i do a preg replace for this email address [email protected] to [email protected] Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/ Share on other sites More sharing options...
mbeals Posted July 2, 2008 Share Posted July 2, 2008 you just want to replace that one email address with the other? is it alone in a variable or contained in a string? Lets assume it's contained in a string with other stuff. Since it is a simple match and replace, use str_replace instead, as it's MUCH quicker then preg_replace... only use preg functions if you have to. $string = str_replace("[email protected]", "[email protected]", $string); Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/#findComment-580090 Share on other sites More sharing options...
perezf Posted July 2, 2008 Author Share Posted July 2, 2008 that didnt work thats the first thing i tried, but for some reason its not working. So how can i do it with preg replace Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/#findComment-580093 Share on other sites More sharing options...
Jabop Posted July 2, 2008 Share Posted July 2, 2008 that didnt work thats the first thing i tried, but for some reason its not working. So how can i do it with preg replace If the scenario you provided in your first post is true, the first reply to this thread would do it. Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/#findComment-580099 Share on other sites More sharing options...
perezf Posted July 2, 2008 Author Share Posted July 2, 2008 i know but for some reason its not working. i believe since the string is coming from a DB its not working properly Thats why i want to try it using preg_replace? does anyone know how to do that. Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/#findComment-580102 Share on other sites More sharing options...
mbeals Posted July 2, 2008 Share Posted July 2, 2008 can you post the input string? preg_replace will do the exact same thing when it's just looking for a string. If str_replace doesn't work, preg_replace probably won't either. run: echo $string; $string = str_replace("[email protected]", "[email protected]", $string); echo $string; and post what the result is Link to comment https://forums.phpfreaks.com/topic/112931-preg-replace/#findComment-580104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.