mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +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
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