Files
php_8/regexp/email.php
2022-05-18 20:23:05 +03:00

15 lines
272 B
PHP

<?php
$text = 'Адреса: user-first@mail.ru, second.user@mail.ru.';
$html = preg_replace(
'{
[-\w.]+ # имя ящика
@
[-\w]+(\.[-\w]+)* # имя хоста
}xs',
'<a href="mailto:$0">$0</a>',
$text
);
echo $html;