From a64bfde6afd073a8f387ca20243491d077711b84 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 18 Mar 2025 15:07:55 +0100 Subject: [PATCH] Added findIgnoreCase() utility function. --- source/mijin/util/string.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/mijin/util/string.hpp b/source/mijin/util/string.hpp index d830af5..5dab3cf 100644 --- a/source/mijin/util/string.hpp +++ b/source/mijin/util/string.hpp @@ -387,6 +387,15 @@ constexpr bool isHexadecimalChar(TChar chr) noexcept || (chr >= TChar('a') && chr <= TChar('f')); } +[[nodiscard]] +inline auto findIgnoreCase(std::string_view haystack, std::string_view needle) +{ + return std::ranges::search(haystack, needle, [](char left, char right) + { + return std::tolower(left) == std::tolower(right); + }); +} + namespace pipe { struct Join