O'Reilly logo

Java 9 Regular Expressions by Anubhava Srivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Methods - String split methods

The String class has two split methods with the following signatures:

  • String[] split(String regex, int limit)
  • String[] split(String regex)

These split methods split the subject string into an array around the matches of the given regular expression, also called delimiters.

When there is a positive width match at the beginning of an input string, then an empty string is included at the beginning of the resulting array. However, a match of zero width by regular expression does not include any empty string at the beginning of the resulting array.

The array returned by this method contains a combination of the following elements:

  • Token substrings that are split by the delimiter, matched using the given regular ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required