Hey.
I can not deal with regulars. Her task is to parse the text and replace the email addresses with mailto links:
$text = preg_replace("#(^|[\n ])([\w0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#iu", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $text);
Everything works only when there are any characters in front of the address. For example:
test@test.com - does not work.
test test@test.com - works.
UPD: It turned out that the prefilter of the line adds <p>
at the beginning. I am not very strong in regulars, so I’ll additionally ask if such a solution to the problem is normal:
(^|>|[\n ])([\w0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)
"#^([\n\s]*)([\w&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*\w+)#iu"
- etki