AK: Add count() helper to String

This commit is contained in:
thankyouverycool 2023-04-29 10:41:25 -04:00 committed by Andreas Kling
parent f3dbfb85d9
commit 9a03e4dd73

View file

@ -138,6 +138,8 @@ public:
// Returns a StringView covering the full length of the string. Note that iterating this will go byte-at-a-time, not code-point-at-a-time.
[[nodiscard]] StringView bytes_as_string_view() const;
[[nodiscard]] size_t count(StringView needle) const { return StringUtils::count(bytes_as_string_view(), needle); }
ErrorOr<String> replace(StringView needle, StringView replacement, ReplaceMode replace_mode) const;
ErrorOr<String> reverse() const;