【发布时间】:2010-12-04 01:30:05
【问题描述】:
如何将单词拆分为其组成字母?
无效的代码示例
class Test {
public static void main( String[] args) {
String[] result = "Stack Me 123 Heppa1 oeu".split("\\a");
// output should be
// S
// t
// a
// c
// k
// M
// e
// H
// e
// ...
for ( int x=0; x<result.length; x++) {
System.out.println(result[x] + "\n");
}
}
}
问题似乎出在字符\\a 上。
它应该是 [A-Za-z]。
【问题讨论】:
-
你的例子并没有说明你是否想要拆分“123”。
-
patros:我不希望“123”被拆分。