<?php $pattern = "/([a-zA-Z0-9+._-]+)@([a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/"; $template = '<a email-a="%s" email-b="%s">[click to email]</a>'; $str = "bla bla bla firstbit@secondbit.com bla bla bla"; $newStr = preg_replace_callback($pattern, function($matches) use ($template) { [, $local, $host] = $matches; return sprintf($template, $local, $host); }, $str); echo $newStr;
You have javascript disabled. You will not be able to edit any code.