summaryrefslogtreecommitdiff
path: root/AK/StringView.h
diff options
context:
space:
mode:
authorAndrew Kaster <andrewdkaster@gmail.com>2020-05-02 12:21:20 -0600
committerAndreas Kling <kling@serenityos.org>2020-05-04 09:39:05 +0200
commit3eb3c2477fbacff9bbeac771c1d2ecc4ddec03e7 (patch)
tree745d36ca934faf16728a623bef42b20a0ea22b13 /AK/StringView.h
parent94c28552c6e29cebd83bf48084262c1003f7baab (diff)
downloadserenity-3eb3c2477fbacff9bbeac771c1d2ecc4ddec03e7.zip
AK: Add StringView::find_first/last_of
These methods search from the beginning or end of a string for the first character in the input StringView and returns the position in the string of the first match. Note that this is not a substring match. Each comes with single char overloads for efficiency.
Diffstat (limited to 'AK/StringView.h')
-rw-r--r--AK/StringView.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/AK/StringView.h b/AK/StringView.h
index 491e1cf2c3..3d7105888d 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -79,6 +79,12 @@ public:
bool matches(const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
bool contains(char) const;
+ Optional<size_t> find_first_of(char) const;
+ Optional<size_t> find_first_of(const StringView&) const;
+
+ Optional<size_t> find_last_of(char) const;
+ Optional<size_t> find_last_of(const StringView&) const;
+
StringView substring_view(size_t start, size_t length) const;
Vector<StringView> split_view(char, bool keep_empty = false) const;