Reputation: 4232
I want to remove empty space from the first String and make it look like the second String.
1)EVANS MD JOSEPH J
2)EVANS MD JOSEPH J
My code:
String finaloriginAutoCompleteText = providerOriginAddress.get(position).getProviderName();
Upvotes: 0
Views: 4036
Reputation: 2643
String finaloriginAutoCompleteText;
finaloriginAutoCompleteText = providerOriginAddress.get(position).getProviderName();
// trim the string (for leading and ending whitespaces) and then
// replace all remaining (inner) multiple spaces (\s+) with a single space (" ")
finaloriginAutoCompleteText = finaloriginAutoCompleteText.trim().replaceAll("\\s+", " ");
Upvotes: 1