AK: Add trim_ascii_whitespace method to String

This commit is contained in:
aryanbaburajan 2023-07-07 13:22:36 +05:30 committed by Jelle Raaijmakers
parent bc8cad31de
commit a94c0eea94
Notes: sideshowbarker 2024-07-17 07:25:39 +09:00
2 changed files with 6 additions and 0 deletions

View File

@ -484,6 +484,11 @@ ErrorOr<String> String::trim(StringView code_points_to_trim, TrimMode mode) cons
return trim(Utf8View { code_points_to_trim }, mode);
}
ErrorOr<String> String::trim_ascii_whitespace(TrimMode mode) const
{
return trim(" \n\t\v\f\r"sv, mode);
}
bool String::contains(StringView needle, CaseSensitivity case_sensitivity) const
{
return StringUtils::contains(bytes_as_string_view(), needle, case_sensitivity);

View File

@ -150,6 +150,7 @@ public:
ErrorOr<String> trim(Utf8View const& code_points_to_trim, TrimMode mode = TrimMode::Both) const;
ErrorOr<String> trim(StringView code_points_to_trim, TrimMode mode = TrimMode::Both) const;
ErrorOr<String> trim_ascii_whitespace(TrimMode mode = TrimMode::Both) const;
ErrorOr<Vector<String>> split_limit(u32 separator, size_t limit, SplitBehavior = SplitBehavior::Nothing) const;
ErrorOr<Vector<String>> split(u32 separator, SplitBehavior = SplitBehavior::Nothing) const;