假设我有以下字符串:
String asd = "this is test ass this is test"
我想用"屁股"字符序列拆分字符串.
我用了:
asd.split("ass");
它不起作用.我需要做什么?
它似乎对我很好:
public class Test { public static void main(String[] args) { String asd = "this is test ass this is test"; String[] bits = asd.split("ass"); for (String bit : bits) { System.out.println("'" + bit + "'"); } } }
结果:
'this is test ' ' this is test'
您真正的定界符可能不同吗?不要忘记split将其参数用作正则表达式...