mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
AK: Add StringView::count(char)
This commit is contained in:
parent
b40ab55830
commit
3556c27d2d
3 changed files with 16 additions and 0 deletions
|
@ -593,6 +593,16 @@ size_t count(StringView str, StringView needle)
|
|||
return count;
|
||||
}
|
||||
|
||||
size_t count(StringView str, char needle)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < str.length(); ++i) {
|
||||
if (str[i] == needle)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue