split
public String[] split(String regex)
Splits this string around matches of the given regular expression.
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }
Parameters:
regex - the delimiting regular expression
Returns:
the array of strings computed by splitting this string around matches of the given regular expression
Throws:
PatternSyntaxException - if the regular expression's syntax is invalid
NullPointerException - if regex is null
Since:
1.4
See Also:
PatternAPI上是这么说的,可能是和数组写发有关吧
public String[] split(String regex)
Splits this string around matches of the given regular expression.
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }
Parameters:
regex - the delimiting regular expression
Returns:
the array of strings computed by splitting this string around matches of the given regular expression
Throws:
PatternSyntaxException - if the regular expression's syntax is invalid
NullPointerException - if regex is null
Since:
1.4
See Also:
PatternAPI上是这么说的,可能是和数组写发有关吧
解决方案 »
- java 把string里的内容传到Array/ArrayList中 并纪录offset
- 请问ArrayList和List有什么差别?
- 急急急!!关于界面布局
- 问下JDK1.4版的用什么语法输入呀?
- try catch finally的问题
- ★★★请高手指点:如何使用ButtonGroup★★★
- 为什么如下错误?
- 怎样在JAVA中直接调用WINDOWS 本地的 FileChooser, Swing 自带的那个又丑又慢,还不能连接共享计算机文件夹
- 如何在程序里面加入帮助文件??
- 请问哪个中文网站有下载java虚拟机!
- BBS中怎样获取在线用户列表?(我已经在很多BBS上发贴了。但还没找到解决办法的。。。)
- Crob FTP Server并发用户测试,免费开放FTP,欢迎参加
"Predefined character classes
. Any character (may or may not match line terminators) "
此处“.”和“,”不同,“”表示的不是字符“.”而是表示line terminators
而“,”则表示字符“,”
如果你在程序中引用“,”,代码如下
就不会有问题
public class Test1
{
public static void main(String[] args)
{
String str = "faasdf,faf";
String[] s = str.split(",");
System.out.println(s[0]);
}
}