【发布时间】:2014-07-22 20:51:16
【问题描述】:
给定:
String one = "show ip interface brief | include 1234**\n Gi1/23.1234 xxx.225.xxx.106 YES manual up up";
我要分手
Gi1/23.1234 xxx.225.xxx.106 YES manual up up
放入不同的令牌并删除
show ip interface brief | include 1234**
输出应该是:
String[] tokens = ["Gi1/23.1234", "xxx.225.xxx.106", "Yes", "manual", "up", "up"]
【问题讨论】:
-
嗯……你说的。使用 String 类的 split() 方法
-
您的帖子几乎无法阅读。无论如何,您是否尝试过任何方法,例如 String 类中的
split方法?我们可以看看你的尝试吗? -
是的,我已经尝试过,但我无法从 Gil 开始拆分第二行。因为拆分方法不拆分“|” .请如果你能做任何帮助它真的很紧急
-
您必须转义
regex字符"|"。示例:string.split("\\|")
标签: java regex string split tokenize