gpt4 book ai didi

php - 将循环中的 str_replace() 更改为单个 preg_replace() 调用?

转载 作者:行者123 更新时间:2023-12-04 06:27:58 24 4
gpt4 key购买 nike

你怎么把它改成 preg_replace()等效(不使用循环)?

注:$text是 utf-8。

  do $text = str_replace("* *", "*", $text, $totRepla); while ($totRepla);

最佳答案

我相信正则表达式模式可以匹配任意长的 * * * * * *

/(\* )*\*/

请自己添加其余的代码,我现在手头没有 PHP,无法提供完整的代码片段。

关于php - 将循环中的 str_replace() 更改为单个 preg_replace() 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5808938/

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