1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +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:
Max Wipfli 2021-05-25 09:42:01 +02:00 committed by Andreas Kling
parent 14506e8f5e
commit 0e4f7aa8e8
4 changed files with 17 additions and 5 deletions

View file

@ -50,7 +50,8 @@ bool ends_with(const StringView& a, const StringView& b, CaseSensitivity);
bool starts_with(const StringView&, const StringView&, CaseSensitivity);
bool contains(const StringView&, const StringView&, CaseSensitivity);
bool is_whitespace(const StringView&);
StringView trim_whitespace(const StringView&, TrimMode mode);
StringView trim(const StringView& string, const StringView& characters, TrimMode mode);
StringView trim_whitespace(const StringView& string, TrimMode mode);
Optional<size_t> find(const StringView& haystack, const StringView& needle);
String to_snakecase(const StringView&);