I was wondering what's the best approach to keep the delimiter with the aftermath String
after its split("-").
So here is the code:
String word = "abc -def ghi -jkl -mno pqr";
String[] strArr= null;
strArr = word.split("-");
...
here we iterate through array
it will print:
abc
def ghi
jkl
mno pqr
but I want to keep the delimiter and it should look something like:
abc
-def ghi
-jkl
-mno pqr
One way is, while iterating, to concatenate the "-" delimiter, but I was wondering if there is a better way.