How can I extract overlapping matches from an input using String.split()
?
For example, if trying to find matches to \"aba\"
:
This is not a correct use of split()
. From the javadocs:
Splits this string around matches of the given regular expression.
Seems to me that you are not trying to split the string but to find all matches of your regular expression in the string. For this you would have to use a Matcher, and some extra code that loops on the Matcher
to find all matches and then creates the array.