3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = ' sdfsdaf sdafadsf #test sdfdsf'; $text = preg_replace('%(\A#(\w|(\p{L}\p{M}?)|-)+\b)|((?<=\s)#(\w|(\p{L}\p{M}?)|-)+\b)|((?<=\[)#.+?(?=\]))%u', '<a class="hashtag" href="https://google.com/?q='.urlencode('$3').'" target="_blank">$3</a>', $text, 10); echo ($text);
based on 6p9jI
Output for 4.4.0 - 4.4.9, 5.0.5 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
sdfsdaf sdafadsf <a class="hashtag" href="https://google.com/?q=%243" target="_blank"></a> sdfdsf
Output for 4.3.11, 5.0.0 - 5.0.4
Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 10 in /in/qNuc6 on line 6
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 10 in /in/qNuc6 on line 6