第一种方法:string s=abcdeabcdeabcde;string[] sArray=s.Split('c') ;foreach(string i in sArray)Console.WriteLine(i.ToString());输出下面的结果:abdeabdeabde 第二种方法:我们看到了结果是以一个指定的字符进行的分割.使用另一种构造方法对多个字符进行分割:string s="abcdeabcdeabcde";string[] sArray1=s.Split(new c
在java doc里有 String[] java.lang.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. Tra
java的split()方法用于字符串中根据指定的字符进行分割,得到的是一个字符串数组 public String[] split(String regex) Splits this string around matches of the given regular expression.split() 方法需要的参数不是一个简单的字符,而是正则表达式 当以"."作为分割符时,不能使用s.split(".") ,而要使用s.split("\\."
场景 出于业务考虑,将多个字符串拼接起来时,使用的分隔符是;,;.如果要将这样一个拼接来的字符串分割成原本的多个字符串时,就需要使用到jdk自带的split()方法.不过因为公司的编程规范,改为使用了Apache工具类的StringUtils.split(). 之后就发现,当被拼接的字符串里含有;或,时,就会出现分割不正确的问题. 具体例子 下面的代码,使用了上述的两种split方法,猜猜结果是什么. public class Test { public static void main(fin
代码: String str = "the music made it hard to concentrate"; String delims = "[ ]+"; String[] tokens = str.split(delims); 结果为: the, music, made, it, hard, to, concentrate 原因: String.split(String regex):参数是一个正则表达式 转自:http://pages.cs.wisc.e