我想在字之间添加字符串xx
,假设这两个字之间既不存在xx
也不存在yy
。实例:php - 如何在字符串中的两个单词之间插入单词?
this house
- >this xx house
this xx house
- >this xx house
this yy house
- >this yy house
this is my house
- >this xx is xx my xx house
this yy is my house
- >this yy is xx my xx house
xx xx
- >xx xx xx
this is my house yy indeed
- >this xx is xx my xx house yy indeed
的想法是,默认情况下插入单词xx
之间的两个词,如果有没有其他xx
也不另一yy
。但是,如果在两个单词的MIDDLE中存在xx
或yy
,请不要添加任何内容。
如何编写此功能?
您是否尝试过的东西来实现自己的目标的答案? – Rizier123
爆炸的空间,循环,有点棘手 –
我试过一些子字符串,但没有什么 – user2580401