Lets say you need to display a text teaser of the actual value, but you want to have all email format to be in “*******”, say
$var = "Please email me at lance@workemail.com or at my private email lance@yahoo.co.uk";
should display as
Please email me at ******************* or at my private email ******************
How would you accomplish this? Is there a way to use str_replace to match a particular regular expression then replace that with a fix ten character asterisk? I wanted to hear your opinions
Thanks! That was fast, you didn’t make it look like it was tricky in any sense.
Follow up question since im not much of a preg_match user, the reg expression you provided is rather lengthy than the usual, can u explain the part where there is “aero|coop|info|museum|name”?
one more thing, you missed an additional parameter on the str_replace line
That’s probably overly lengthy in a lot of respects, but it depends on your content.
With regards to “aero|coop|info|museum|name”, it is in addition to “[a-zA-Z]{2,3}” which checks for things like .us or .com, but not, say, 6 letter TLD like museum.