summaryrefslogtreecommitdiff
path: root/AK/String.h
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2023-04-29 10:41:25 -0400
committerAndreas Kling <kling@serenityos.org>2023-04-30 05:48:14 +0200
commit9a03e4dd7325733a7b6928e296495fc8ca670375 (patch)
treee7d0c4932d8bc43d8b21dfc5f96cdef4f2ec4a3f /AK/String.h
parentf3dbfb85d993f3af4c2335edcab678ff9da458c5 (diff)
downloadserenity-9a03e4dd7325733a7b6928e296495fc8ca670375.zip
AK: Add count() helper to String
Diffstat (limited to 'AK/String.h')
-rw-r--r--AK/String.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/AK/String.h b/AK/String.h
index 72f3650469..b69cf95fd5 100644
--- a/AK/String.h
+++ b/AK/String.h
@@ -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;