mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
AK: Add a helper to get the last split-group
This commit is contained in:
parent
96276c87cf
commit
154871834b
Notes:
sideshowbarker
2024-07-17 10:16:43 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/154871834b Pull-request: https://github.com/SerenityOS/serenity/pull/14326 Issue: https://github.com/SerenityOS/serenity/issues/14266 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/timschumi ✅
@ -159,6 +159,8 @@ public:
|
||||
using SearchDirection = StringUtils::SearchDirection;
|
||||
[[nodiscard]] Optional<size_t> find_any_of(StringView needles, SearchDirection direction) const { return StringUtils::find_any_of(*this, needles, direction); }
|
||||
|
||||
[[nodiscard]] StringView find_last_split_view(char separator) const { return view().find_last_split_view(separator); }
|
||||
|
||||
[[nodiscard]] String substring(size_t start, size_t length) const;
|
||||
[[nodiscard]] String substring(size_t start) const;
|
||||
[[nodiscard]] StringView substring_view(size_t start, size_t length) const;
|
||||
|
@ -127,6 +127,14 @@ public:
|
||||
|
||||
[[nodiscard]] Vector<StringView> split_view_if(Function<bool(char)> const& predicate, bool keep_empty = false) const;
|
||||
|
||||
[[nodiscard]] StringView find_last_split_view(char separator) const
|
||||
{
|
||||
auto begin = find_last(separator);
|
||||
if (!begin.has_value())
|
||||
return *this;
|
||||
return substring_view(begin.release_value() + 1);
|
||||
}
|
||||
|
||||
template<VoidFunction<StringView> Callback>
|
||||
void for_each_split_view(char separator, bool keep_empty, Callback callback) const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user