use*_*778 -1 java string split
假设我有以下字符串:
String asd = "this is test ass this is test"
Run Code Online (Sandbox Code Playgroud)
我想用"屁股"字符序列拆分字符串.
我用了:
asd.split("ass");
Run Code Online (Sandbox Code Playgroud)
它不起作用.我需要做什么?
它似乎对我很好:
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 + "'");
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
'this is test '
' this is test'
Run Code Online (Sandbox Code Playgroud)
您真正的定界符可能不同吗?不要忘记split将其参数用作正则表达式...