我正在尝试找到一种替换这样的文本的方法:
或者-----------------------------------
这句话的意思是,我们将开始一个文本部分,以“ABC”开头并以“CED”结尾,用“替换文本”替换它们之间的所有文本。您该如何做到这一点呢?谢谢。
text here ABC -some text here- CED text here
to
text here ABC -replaced text- CED text here
或者-----------------------------------
text here ABC - some description here- CED text here
to
text here ABC - replaced text- CED text here
这句话的意思是,我们将开始一个文本部分,以“ABC”开头并以“CED”结尾,用“替换文本”替换它们之间的所有文本。您该如何做到这一点呢?谢谢。
preg_replace('/ABC(.*?)CED/', 'ABC - new - CED', $string);
- Mihai Iorga