![]() |
VOOZH | about |
The StringUtils.substringsBetween() the method provided by the Apache Commons Lang library is used to extract multiple substrings from the larger string. It returns an array of the substrings that lie between two specified delimiters.
Note: Add the
org.apache.commons.lang3library to Project.
public static String[] substringsBetween(String str, String open, String close)
Return Value: An array of the substrings that are located between the specified opening and closing delimiters.
In this example, we will print the substrings present between {}
world
are
doing
In this example, we will print the substrings present between []
quick
brown
fox
lazy
dog
Note: Alternatively, you can use String[] substrings = input.split("\\{([^}]+)\\}"); to get the array of substrings between the delimiters.