how to split string with some seperator but without removing that seperator in Java?
- by sag
Hi,
I m facing problem in splitting string.
Actually i want to split a string with some seperator but without loosing that seperator.
when we use somestring.split(String seperator) method in java it splits the string but removes the seperator part from string.It should not happen.
I want result like below:
Example::string1="Ram-sita-laxman";
seperator="-";
string1.split(seperator);
output : [Ram, sita, laxman]
but i want the result like :[Ram, -sita, -laxman]
is there a way to get output like this?