I know the split can be done with split
functionality of java. I did that like in the below code
String[] sArr = name.split("[\\s.]+");
String newStr = "";
for (int i = 0; i < sArr.length; i++){
newStr = newStr + " " + mymethod(sArr[i]);
}
What i actually want to do is all the words in the string must pass through mymethod
and reform the string. But on reforming i dont want to loss the dots and spaces which is actually there. For example Mr. John
will remove the dot after reforming and would change in to Mr John
which i don't want. So how to reform my string without losing anything in that actual string, but also each word to pass through mymethod
also. Thanks in advance!