3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = 'say hello to @elise_123.com and @john-abc'; function replace_at_symbol($matches){ $username = str_replace("@", "", $matches[0]); return '<a href="/profile/'.$username.'">'.$matches[0].'</a>';} $output = preg_replace_callback("/([@][-_a-zA-Z-0-9]+)/", "replace_at_symbol", $text); echo $output; ?>
based on ECk6r
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
say hello to <a href="/profile/elise_123">@elise_123</a>.com and <a href="/profile/john-abc">@john-abc</a>