Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

groovy
split()
communitycreator

What is split() in groovy?

Sheza Naveed

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

split() is a function in groovy that splits the String around matches of the given regular expression.

Syntax


String[] split(String regex)

Parameters

The function takes in one parameter regex. regex is the delimiting regular expression.

Return value

The function returns the array of strings calculated by splitting the string around matches of regex.

Code

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

Output

Hello
Edpresso

RELATED TAGS

groovy
split()
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring