I am having a string "role1@role2@role3@role4$arole" separated with delimiter @ and $. I used below java code
String str = "role1@role2@role3@role4$arole"; String[] values = StringUtils.splitPreserveAllTokens(str, "\\@\\$"); for (String value : values) { System.out.println(value); } And got the result
role1 role2 role3 role4 arole But my requirement is to preserve the delimiter in the result. So, the result has to be as per requirement
role1 @role2 @role3 @role4 $arole I analyzed the apache commons StringUtils method to do that but was unable to found any clue.
Any library class to get the above intended results?