How do I check whether input string contains any spaces? September 15, 2023 by Tarik Why use a regex? name.contains(" ") That should work just as well, and be faster.