在分隔符的第三个实例上分割字符串
我有一些这种格式的测试用例/字符串:
o201_01_01a_Testing_to_see_If_this_testcases_passes:without_data
o201_01_01b_Testing_to_see_If_this_testcases_passes:data
rx01_01_03d_Testing_the_reconfiguration/Retest:
实际上这个测试用例名称由实际名称和描述组成。
所以,我想像这样分割它们:
o201_01_01a Testing_to_see_If_this_testcases_passes:without_data
o201_01_01b Testing_to_see_If_this_testcases_passes:data
rx01_01_03d Testing_the_reconfiguration/Retest:
我无法弄清楚在 php 中爆炸中执行此操作的确切方法
有人可以帮忙吗?
谢谢。
I have some testcases/strings in this format:
o201_01_01a_Testing_to_see_If_this_testcases_passes:without_data
o201_01_01b_Testing_to_see_If_this_testcases_passes:data
rx01_01_03d_Testing_the_reconfiguration/Retest:
Actually this testcase name consists of the actual name and the description.
So, I want to split them like this :
o201_01_01a Testing_to_see_If_this_testcases_passes:without_data
o201_01_01b Testing_to_see_If_this_testcases_passes:data
rx01_01_03d Testing_the_reconfiguration/Retest:
I am unable to figure out the exact way to do this in explode in php
Can anyone help please?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果第一部分始终具有相同的长度,为什么不使用
substr
,例如If the first part has always the same length, why don't you use
substr
, e.g.如果我的正则表达式正确的话,这应该会给你一系列结果。
http://www.php.net/manual/en/function。 preg-split.php
That should give you an array of results, provided I got the regular expression correct.
http://www.php.net/manual/en/function.preg-split.php
查看该模式,看来您需要使用正则表达式。如果都是这样,您可以通过查找大写字符来截断开头。代码可能如下所示:
将第一个小部分放入 $matches 中。正在制作第二部分...
Looking at the pattern, it appears that you need to use regular expressions. If this is how they all are, you can cut off the beginning by looking for an upper case character. The code might look like this:
Would put the first little part into $matches. Working on second part...