mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
AK: Add a helper to get the last split-group
This commit is contained in:
parent
96276c87cf
commit
154871834b
2 changed files with 10 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue