仅当冒号是字符串的第一个字符时,我才想删除它。我已经尝试过以下方法,但它不起作用。任何帮助将不胜感激:
//remove the colon if its the first character..
$pattern = '/^:/';
$replace = '';
$tweet = preg_replace($pattern, $replace, $tweet);
最佳答案
转义冒号:
$pattern = '/^\\:/';
关于php - 如果冒号是第一个字符,则删除它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10371175/