public class AssertTest {
public static void main(String[] args) {
String test = "abcdefghi";
String[] tokens = test.split("\\e");
for(String a: tokens){
System.out.println(a);
}
}}
public static void main(String[] args) {
String test = "abcdefghi";
String[] tokens = test.split("\\e");
for(String a: tokens){
System.out.println(a);
}
}}
解决方案 »
- 异常a different object with the same identifier value was already associated with
- 如何利用JMF控制当前音量
- 菜鸟问个初级问题:JAVA的类名为什么都能点出class?这个是从哪里来的?
- 求与group by有关的SQL,100分相送
- 使用vector遇到的问题!!请大家指教!!
- 一个在constructor里调用动态绑定的方法的问题
- 我要向文件读写数据?
- 如何用C语言调用JAVA的类文件啊?
- 谁有“计算器”的源码呀!最好是手写的非ide编写的!谢谢
- 如何使JBOSS作为Windows2000的一项服务启动???
- 关于JTree控件的几个小问题,望高手指教·········
- 解释下java的求模运算~17.25%0.7=?
public static void main(String[] args) {
String test = "This is a test";
String[] tokens = test.split("\\s");
System.out.println(tokens.length);
}}为什么这样我能成功。
String test = "This is a test";split后的元素是3个独立单词。
但是 \\e,也就是\e, 不是一个转义字符,所以无法识别
String test = "abcdefgh\\eggggggehhhhhh\\exyz";
System.out.println(test);
String[] tokens = test.split("\\\\e");
for (String a : tokens) {
System.out.println(a);
}关于java正则的转义,我的理解是字符串字面输入存到字符串要转义1次,然后字符串获得\后交给正则引擎看的时候又转义一次,就形成了4个变2个,2个变1个的最终效果。