正在检测hash标记并srip#以获得干净的url


Detecting hash tag and srip the # for clean url

考虑字符串:

$tring = 'e.g. i want to #sleep.';

我能够使用检查哈希标签

echo preg_replace('/(#'w+)/', ''1', $tring);

我想做的是发送前面没有散列的标签,即sleep而不是#sleep

我想你想要:

echo preg_replace('/#/', '', $tring);

echo preg_replace('/.+?#(.+?)/', ''1', $tring);