java关于split分割字符串,空的字符串不能得到的问题 class T { public static void main(String args[]) { String num[] = new String[11]; String sLine = "101494|360103660318444|2008/06/17|周润英|1292.0|3085.76|2778.28|912.91|106.0|||"; num = sLine.split("\\|");…
今天使用split分割"."的时候居然失败了,经过百度发现原来要加转义字符才行. 正确的写法: String test="1.2.3"; String[] s1=test.split("\\."); 结果: 如果不加转义就会分割失败,返回一个空的字符串数组. API中是这样写的: public String[] split(String regex) Splits this string around matches of the given r…
总结:正则表达式-- package com.c2; //写一个spli的用法,数字类 ===分割字符串 public class yqw { public static void main(String[] args) { String a = "192.168.43.130"; String c[] = a.split("\\.");// 数组 for (int i = 0; i < c.length; i++) { System.out.println(…
spilt方法作用 以所有匹配regex的子串为分隔符,将input划分为多个子串. 例如: The input "boo:and:foo", for example, yields the following results with these expressions: Regex Result :{ "boo", "and", "foo" } o { "b", "", "…
使用split分割时: String[] a="aa|bb|cc".split("|"); output: [a, a, |, b, b, |, c, c] 先看一下split的用法: String[] java.lang.String.split(String regex) Splits this string around matches of the given regular expression. This method works as if by in…