gpt4 book ai didi

php - 如果它是第一个字符,请删除冒号

转载 作者:行者123 更新时间:2023-12-02 22:43:40 25 4
gpt4 key购买 nike

只有当冒号是字符串的第一个字符时,我才想删除它。我尝试了以下但它不起作用。任何帮助将不胜感激:

//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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com