diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-05-25 09:42:01 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-01 09:28:05 +0200 |
commit | 0e4f7aa8e84188a17353fc3a68bca78f94325b0d (patch) | |
tree | 3803e4ea53b3fbf43129e0d24d93d643d1115f5a /AK/StringView.h | |
parent | 14506e8f5ebe5677f389435a7f22c7e36f903169 (diff) | |
download | serenity-0e4f7aa8e84188a17353fc3a68bca78f94325b0d.zip |
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.
Diffstat (limited to 'AK/StringView.h')
-rw-r--r-- | AK/StringView.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/AK/StringView.h b/AK/StringView.h index dab15292fb..d7738f08ed 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -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; |