Shorter IsLowercase() with Regex

Just wanted to share my ContainsInvalidCharacters() which is what I named my !IsLowercase() method. I know regex is a more complicated machine than an intro course needs, but for those who haven’t seen it or who have used it before, I think this works pretty nicely and reads cleanly.

// Checks if there are any characters that aren't a-z
bool FBullCowGame::ContainsInvalidCharacters(FString Guess) const
	std::regex r("[^a-z]");
	return std::regex_search(Guess, r);

Privacy & Terms