mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
AK: Add a StringView method to count the number of lines in a string
We already have a helper to split a StringView by line while considering "\n", "\r", and "\r\n". Add an analagous method to just count the number of lines in the same manner.
This commit is contained in:
parent
07a27b2ec0
commit
82ea53cf10
3 changed files with 79 additions and 30 deletions
|
@ -240,6 +240,7 @@ public:
|
|||
Yes,
|
||||
};
|
||||
[[nodiscard]] Vector<StringView> lines(ConsiderCarriageReturn = ConsiderCarriageReturn::Yes) const;
|
||||
[[nodiscard]] size_t count_lines(ConsiderCarriageReturn = ConsiderCarriageReturn::Yes) const;
|
||||
|
||||
// Create a new substring view of this string view, starting either at the beginning of
|
||||
// the given substring view, or after its end, and continuing until the end of this string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue