Skip to content

Instantly share code, notes, and snippets.

@mattearly
Created April 16, 2017 00:38
Show Gist options
  • Save mattearly/c3b2ec7e428b290c3cdcd551adef5946 to your computer and use it in GitHub Desktop.
Save mattearly/c3b2ec7e428b290c3cdcd551adef5946 to your computer and use it in GitHub Desktop.
function for searching without caring about case matching
#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