AK: Add contains(char) method to String

This commit is contained in:
Jean-Baptiste Boric 2021-08-11 20:49:32 +02:00 committed by Andreas Kling
parent a29788e58a
commit 7a9d05c24c
Notes: sideshowbarker 2024-07-18 07:06:05 +09:00
2 changed files with 6 additions and 0 deletions

View file

@ -341,6 +341,11 @@ bool String::contains(const StringView& needle, CaseSensitivity case_sensitivity
return StringUtils::contains(*this, needle, case_sensitivity);
}
bool String::contains(char needle, CaseSensitivity case_sensitivity) const
{
return StringUtils::contains(*this, StringView(&needle, 1), case_sensitivity);
}
bool String::equals_ignoring_case(const StringView& other) const
{
return StringUtils::equals_ignoring_case(view(), other);

View file

@ -138,6 +138,7 @@ public:
[[nodiscard]] bool equals_ignoring_case(const StringView&) const;
[[nodiscard]] bool contains(const StringView&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] bool contains(char, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] Vector<String> split_limit(char separator, size_t limit, bool keep_empty = false) const;
[[nodiscard]] Vector<String> split(char separator, bool keep_empty = false) const;