mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
AK: Add String::trim
This commit is contained in:
parent
cccaa94767
commit
c59268d15b
Notes:
sideshowbarker
2024-07-17 02:35:27 +09:00
Author: https://github.com/trflynn89
Commit: c59268d15b
Pull-request: https://github.com/SerenityOS/serenity/pull/17206
Reviewed-by: https://github.com/linusg ✅
3 changed files with 126 additions and 0 deletions
|
@ -438,6 +438,17 @@ ErrorOr<String> String::reverse() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
ErrorOr<String> String::trim(Utf8View const& code_points_to_trim, TrimMode mode) const
|
||||
{
|
||||
auto trimmed = code_points().trim(code_points_to_trim, mode);
|
||||
return String::from_utf8(trimmed.as_string());
|
||||
}
|
||||
|
||||
ErrorOr<String> String::trim(StringView code_points_to_trim, TrimMode mode) const
|
||||
{
|
||||
return trim(Utf8View { code_points_to_trim }, mode);
|
||||
}
|
||||
|
||||
bool String::contains(StringView needle, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return StringUtils::contains(bytes_as_string_view(), needle, case_sensitivity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue