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

The limit parameter rules

The limit parameter controls the number of times the regular expression pattern is applied for splitting the subject string. It affects the length of the resulting array with the following rules:

  1. If the limit is greater than 0, then the pattern will be applied at most one time, the resulting array's length will not be greater than the limit, and the array's last entry will contain all input substrings beyond the last matched delimiter.
  2. If the limit is negative, then the pattern will be applied as many times as possible, and the resulting array can have any length.
  3. If the limit is zero (as in the single parameter split method call), then the pattern will be applied as many times as possible, the array can have any ...

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