PHP Preg Replace“ time = 32.7 word / s”

问题描述 投票:-1回答:1

从生成的文档替换time=32.7 word/s时遇到很多麻烦。

此正则表达式(?s)time\=[0-9].*\/s在崇高的文本中对我来说工作得很好,但我不知道如何通过PHP实现它。

我到底要你们什么?

所以我可以访问的所有文本文件都以time=(seconds)(space)word/s结尾

请帮助我实现preg_replace以使用null(没有空格,什么都没有)过滤它

谢谢!

php regex preg-replace
1个回答
0
投票

您应该查看preg_replace的文档:https://www.php.net/manual/en/function.preg-replace.php

$text = 'lorem123time=32.7 word/s456ipsum';

print(preg_replace('/(?s)time\=[0-9].*\/s/','',$text)); //lorem123456ipsum
© www.soinside.com 2019 - 2024. All rights reserved.