必须对"."进行转意
“ . ”在正则表达式中有特殊的含义,因此我们使用的时候必须进行转义。
- public static void main(string[] args) {
- string value = "192.168.128.33";
- string[] names = value.split("\\.");
- for (int i = 0; i < names.length; i++) {
- system.out.println(names[i]);
- }}
String str = "192.0.0.1";
String[] array = new String[]{};
array = str.split("[.]");