mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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
|
@ -79,6 +79,7 @@ public:
|
|||
[[nodiscard]] bool contains(const StringView&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
[[nodiscard]] bool equals_ignoring_case(const StringView& other) const;
|
||||
|
||||
[[nodiscard]] StringView trim(const StringView& characters, TrimMode mode = TrimMode::Both) const { return StringUtils::trim(*this, characters, mode); }
|
||||
[[nodiscard]] StringView trim_whitespace(TrimMode mode = TrimMode::Both) const { return StringUtils::trim_whitespace(*this, mode); }
|
||||
|
||||
Optional<size_t> find_first_of(char) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue