string.split()方法

p(String.valueOf("5".split("\\.").length));     //print "1"

p(String.valueOf(".5".split("\\.").length));    //print "2"

p(String.valueOf("\"\".5".split("\\.").length));//print "2"

p(String.valueOf("5.".split("\\.").length));    //print "1"

p(String.valueOf("5.\"\"".split("\\.").length));//print "2"

p(String.valueOf("".split("hi").length));//print "1"

p(String.valueOf("hi?".split("\\?").length)); //pring "1"

还有:

"  hi".split("\\s+") = {"","hi"}

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.