字符串拆分基于Ç

时间:2012-10-11 07:22:32

标签: java string-split

我想基于Ç(拉丁大写字母C和cedilla)拆分字符串 到目前为止,我已经尝试过string.split,Splitter.on(pattern).split(line)

Ç有unicode 00C7

2 个答案:

答案 0 :(得分:2)

如果你的java源文件是UTF-8,那么这完全有用:

String[] token = s.split("Ç");

如果没有,请使用

String[] token = s.split("\u00C7"); // Ç

但这不太可读

答案 1 :(得分:2)

尝试

String s = "I want to split a string based on Ç (Latin Capital letter C with cedilla) so far i have tried string.split, Splitter.on(pattern).split(line)\n" +
        "\n" +
        "Ç has unicode 00C7";
for(String part: s.split("Ç"))
    System.out.println("["+part+"]");

打印

[I want to split a string based on ]
[ (Latin Capital letter C with cedilla) so far i have tried string.split, Splitter.on(pattern).split(line)

]
[ has unicode 00C7]