相关文章推荐
犯傻的黄豆  ·  Branches API | GitLab ...·  1 月前    · 
聪明伶俐的单杠  ·  SuperMap iObjects ...·  3 天前    · 
行走的小摩托  ·  Linux ...·  2 年前    · 
腼腆的椅子  ·  码制_百度百科·  2 年前    · 

将此String拆分为给定正则表达式的匹配项。

句法

String[] split(String regex)

参数

regex - 定界正则表达式。

返回值

它返回通过围绕给定正则表达式的匹配拆分此字符串计算的字符串数组。

例子

下面是一个使用这个方法的例子 -

class Example {
   static void main(String[] args) {
      String a = "Hello-World";
      String[] str;
      str = a.split('-');
      for( String values : str )
      println(values);

当我们运行上面的程序,我们将得到以下结果 -

Hello 
World