diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index edc50e62bae..4c4394be150 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -120,6 +120,18 @@ bool Utf8View::contains(u32 needle) const return false; } +bool Utf8View::contains_any_of(ReadonlySpan needles) const +{ + for (u32 const code_point : *this) { + for (auto needle : needles) { + if (code_point == needle) + return true; + } + } + + return false; +} + Utf8View Utf8View::trim(Utf8View const& characters, TrimMode mode) const { size_t substring_start = 0; diff --git a/AK/Utf8View.h b/AK/Utf8View.h index 9158bf669c1..25ea5f304be 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -115,6 +115,7 @@ public: bool is_null() const { return m_string.is_null(); } bool starts_with(Utf8View const&) const; bool contains(u32) const; + bool contains_any_of(ReadonlySpan) const; Utf8View trim(Utf8View const& characters, TrimMode mode = TrimMode::Both) const;