1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

AK: Add StringView::find_last_not

This commit is contained in:
Undefine 2022-09-30 21:19:53 +02:00 committed by Andrew Kaster
parent 48aea321c5
commit 9718667bcf
3 changed files with 11 additions and 0 deletions

View file

@ -388,6 +388,15 @@ Optional<size_t> find_last(StringView haystack, char needle)
return {};
}
Optional<size_t> find_last_not(StringView haystack, char needle)
{
for (size_t i = haystack.length(); i > 0; --i) {
if (haystack[i - 1] != needle)
return i - 1;
}
return {};
}
Vector<size_t> find_all(StringView haystack, StringView needle)
{
Vector<size_t> positions;