1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

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.
This commit is contained in:
Andrew Kaster 2020-05-02 12:21:20 -06:00 committed by Andreas Kling
parent 94c28552c6
commit 3eb3c2477f
3 changed files with 91 additions and 0 deletions

View file

@ -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;