Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只有当它是字符串的第一个字符时,我才想删除冒号。我尝试了以下方法,但它不起作用。任何帮助,将不胜感激:
//remove the colon if its the first character.. $pattern = '/^:/'; $replace = ''; $tweet = preg_replace($pattern, $replace, $tweet);
转义冒号:
$pattern = '/^\\:/';
你也可以把冒号单独放在一个集合中,这样可能更容易阅读:
$pattern = '/^[:]/';