String中split方法以 英文句点 为切割符 的问题
class Test09 {
public static void main(String[] args) {
String str = "www.baidu.com";
String[] split = str.split(".");
//System.out.println(split[0]);//ArrayIndexOutOfBoundsException;
//split的是一个regex,是一个正则表达式。。。。。而”.“在正则表达式中表示所有
String[] split = str.split("\\.");//转译一下就可以了
System.out.println(split[0]);//www
}
} 相关推荐
flyingssky 2020-08-18
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
ChaITSimpleLove 2020-10-06
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26