我一直在寻找一种在每个空格上拆分字符串的方法,直到找到第二个冒号。如果对答案有帮助,我正在使用的语言是 PHP。基本上我想要的是以下字符串:
:foo!bar@cookie.net strawberry cheesecake :hello world: this is a message!
拆分为以下数组:
array(
[0] => ":foo!bar@cookie.net",
[1] => "strawberry",
[2] => "cheesecake",
[3] => ":hello world: this is a message!"
);
我将如何实现这一目标?请注意,不保证冒号存在。输入字符串可能不同,例如Hello World
.