mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 22:28:22 +00:00
AK: Add trim() method to String, StringView and StringUtils
The methods added make it possible to use the trim mechanism with specified characters, unlike trim_whitespace(), which uses predefined characters.
This commit is contained in:
parent
14506e8f5e
commit
0e4f7aa8e8
Notes:
sideshowbarker
2024-07-18 17:04:49 +09:00
Author: https://github.com/MaxWipfli
Commit: 0e4f7aa8e8
Pull-request: https://github.com/SerenityOS/serenity/pull/7478
Reviewed-by: https://github.com/awesomekling
4 changed files with 17 additions and 5 deletions
|
@ -119,9 +119,14 @@ public:
|
|||
[[nodiscard]] bool is_whitespace() const { return StringUtils::is_whitespace(*this); }
|
||||
|
||||
#ifndef KERNEL
|
||||
[[nodiscard]] String trim(const StringView& characters, TrimMode mode = TrimMode::Both) const
|
||||
{
|
||||
return StringUtils::trim(view(), characters, mode);
|
||||
}
|
||||
|
||||
[[nodiscard]] String trim_whitespace(TrimMode mode = TrimMode::Both) const
|
||||
{
|
||||
return StringUtils::trim_whitespace(StringView { characters(), length() }, mode);
|
||||
return StringUtils::trim_whitespace(view(), mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue