java - how can i reduce the number of whitespaces in a sentence to 1 if there are more then 1 whitespaces in the sentence? -
How do I reduce the number of white space 1 in a sentence if the sentence has more than 1 more white space? ?
Assuming that "continuous" white space, here's a solution.
string string = "Hi there are some white spaces here."; String newString = sentence. Riley All ("\\ s +", ""); Println (newString); Output: Hello there are some white spots here.
Comments
Post a Comment