我知道有很多方法将字符串拆分为数组。
但我想知道是否有一个正则表达式,我可以用它来将所有字符串字符拆分为 String[]
数组?
例如:"foo"
-> String[] { "f","o","o" }
String input="foo";
String[] split=input.split( .... )
最佳答案
试试这个:
String []split = input.split("(?!^)");
但是: String []split = input.split("");
会得到 {"","f","o","o"}
关于Java : split string to char array using regex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22452691/