作者:w3a00048_304 | 来源:互联网 | 2023-09-08 07:46
Ivebeentryingtoremoveasectionoftextfromastringthesitesbetweemtwotags.Forexample:
I've been trying to remove a section of text from a string the sites betweem two tags. For example:
我一直试图从两个标签之间的网站中删除一段文字。例如:
This is CROPSTART not very CROPEND cool.
...should become this...
......应该成为......
This is cool.
This is the PHP I've tried and generally it works:
这是我尝试过的PHP,通常它可以工作:
preg_replace('#\/\/CROPSTART[\s\S]+\/\/CROPEND#', '', $string);
However, when the string contains multiple "CROPEND" it crops everything from the CROPSTART to the last CROPEND. I would like it to only crop between the first CROPSTART and the first CROPEND.
但是,当字符串包含多个“CROPEND”时,它会裁剪从CROPSTART到最后一个CROPEND的所有内容。我希望它只能在第一个CROPSTART和第一个CROPEND之间进行裁剪。
Anyone know how to do this?
有人知道怎么做吗?
Thanks Wonko
1 个解决方案