Created
April 16, 2017 00:38
-
-
Save mattearly/c3b2ec7e428b290c3cdcd551adef5946 to your computer and use it in GitHub Desktop.
function for searching without caring about case matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <cctype> | |
bool findStringIC(const std::string & strHaystack, const std::string & strNeedle) { | |
auto it = std::search( | |
strHaystack.begin(), strHaystack.end(), | |
strNeedle.begin(), strNeedle.end(), | |
[](char ch1, char ch2) { return std::tolower(ch1) == std::tolower(ch2); } | |
); | |
return (it != strHaystack.end() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment