Groovy – split()

  • Post author:
  • Post category:Groovy
  • Post comments:2 Comments
Splits

Splits this string around matches of the given regular expression.

Syntax

String[] split(String regex)

Parameters

regex – the delimiting regular expression.

Return Value

It returns the array of strings computed by splitting this string around matches of the given regular expression.

Example

Following is an example of the usage of this method −

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

When we run the above program, we will get the following result −

Hello 
World 

Previous Page:-Click Here

This Post Has 2 Comments

Leave a Reply