I have a program that takes in a string and formats it, ridding it of symbols and setting the case to lower so that it can be processed.
Example:
"Man, this is super trippy!" -> "man this is super trippy"
"YOU are entering a NEW dimension!" -> "you are entering a new dimenstion"
Unfortunately, processing certain strings causes there to be extra whitespaces between words.
Example:
"Wait a minute -- this is too groovy!" -> "wait a minute this is too groovy"
"TONIGHT -- we DINE IN hell!" -> "tonight we dine in hell"
Notice the whitespaces in the latter two examples? For some reason, after processing the strings using this:
line.erase(remove(line.begin(), line.end(), toExclude[i]), line.end());
transform(line.begin(), line.end(), line.begin(), tolower);
where line.erase is called when iterating through the string to remove specific instances of a char, and transform sets the entire thing to lowercase.
Since my program works fine up until I get to strings with hyphens in between words, is there a way to ensure that the maximum whitespaces between words remains at 1?