mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
AK: Add DeprecatedString::find_last(StringView)
This adds the the method DeprecatedString::find_last() as wrapper for StringUtils::find_last for the StringView type.
This commit is contained in:
parent
03107d4028
commit
9a2ee5a9dd
4 changed files with 14 additions and 2 deletions
|
@ -405,6 +405,17 @@ Optional<size_t> find_last(StringView haystack, char needle)
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> find_last(StringView haystack, StringView needle)
|
||||
{
|
||||
for (size_t i = haystack.length(); i > 0; --i) {
|
||||
auto value = StringUtils::find(haystack, needle, i - 1);
|
||||
if (value.has_value())
|
||||
return value;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> find_last_not(StringView haystack, char needle)
|
||||
{
|
||||
for (size_t i = haystack.length(); i > 0; --i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue