I am taking a string as an input and due to some processing later on it is critical that the string does not contain 2 or more consecutive whitepaces anywhere in the string.
For example
string foo = "I am OK" is a valid string
string foo = " I am OK " is a valid string
string foo = " I am OK" is NOT a valid string due to the initial double white space
string foo = "I am OK " is NOT a valid string due to the trailing double whitespaces
string foo = " I am OK " is NOT a valid string since it has 2 whitespaces between am and OK
I think you get the picture, I tried to normalize the string using the following code
string normalizedQuery = apiInputObject.Query.Replace(" ", "");
But this only works I am sure the string has single whitespaces in it, thats why I need to ensure the string never has more so I can use that replace.
How can I make sure the string fits my format?