* @brief Find out if string contains another string, no matter the case. * * @param str String to search in. * @param sub String to search for. * * @return @c true if string contains another string, @c false otherwise. */
| 333 | * @return @c true if string contains another string, @c false otherwise. |
| 334 | */ |
| 335 | bool containsCaseInsensitive(const std::string &str, const std::string &sub) { |
| 336 | if (sub.empty()) { |
| 337 | return true; |
| 338 | } |
| 339 | |
| 340 | auto it = std::search( |
| 341 | str.begin(), str.end(), |
| 342 | sub.begin(), sub.end(), |
| 343 | [](unsigned char ch1, unsigned char ch2) { |
| 344 | return std::tolower(ch1) == std::tolower(ch2); |
| 345 | } |
| 346 | ); |
| 347 | return (it != str.end()); |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * @brief Returns @c true if @a str contains at least one character from |