各位大侠,问个困扰了很久的替换问题。假设有一段文字。
this is a test. just test.我现在要:
1.第一次替换词组 a test ,把 a test 替换为“ [a test] ”
2.第二遍替换单词 test ,替换为“ [test] ”。但不能把第一次替换的“ [a test] ”中的test替换掉。也就是要优先保留 a test , 第二遍把独立单词test替换掉,而不是 a test中的test。我用str_replace两次替换。不行应该怎么办呢?谢谢