mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
AK: Add String::substring(start)
This is a convenience API when you just want the rest of the string starting at some index. We already had substring_view() in the same flavor, so this is a complement to that.
This commit is contained in:
parent
e9280cba13
commit
5d0fda3d39
|
@ -129,6 +129,13 @@ String String::isolated_copy() const
|
|||
return String(move(*impl));
|
||||
}
|
||||
|
||||
String String::substring(size_t start) const
|
||||
{
|
||||
ASSERT(m_impl);
|
||||
ASSERT(start <= length());
|
||||
return { characters() + start, length() - start };
|
||||
}
|
||||
|
||||
String String::substring(size_t start, size_t length) const
|
||||
{
|
||||
if (!length)
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
|
||||
Vector<String> split_limit(char separator, size_t limit, bool keep_empty = false) const;
|
||||
Vector<String> split(char separator, bool keep_empty = false) const;
|
||||
String substring(size_t start) const;
|
||||
String substring(size_t start, size_t length) const;
|
||||
|
||||
Vector<StringView> split_view(char separator, bool keep_empty = false) const;
|
||||
|
|
Loading…
Reference in a new issue