util/StringCompare: add SkipPrefixIgnoreCase()

This commit is contained in:
Max Kellermann 2025-03-10 18:16:28 +01:00
parent eafca183a6
commit b6672004bc

@ -132,3 +132,25 @@ RemoveSuffix(std::basic_string_view<T> &haystack,
haystack.remove_suffix(needle.size());
return match;
}
template<typename T>
constexpr bool
SkipPrefixIgnoreCase(std::basic_string_view<T> &haystack,
std::basic_string_view<T> needle) noexcept
{
bool match = StringStartsWithIgnoreCase(haystack, needle);
if (match)
haystack.remove_prefix(needle.size());
return match;
}
template<typename T>
constexpr bool
RemoveSuffixIgnoreCase(std::basic_string_view<T> &haystack,
std::basic_string_view<T> needle) noexcept
{
bool match = StringEndsWithIgnoreCase(haystack, needle);
if (match)
haystack.remove_suffix(needle.size());
return match;
}