1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "partition_alloc/partition_alloc_base/strings/string_util.h"
6 
7 #include <cstring>
8 
9 namespace partition_alloc::internal::base::strings {
10 
FindLastOf(const char * text,const char * characters)11 const char* FindLastOf(const char* text, const char* characters) {
12   size_t length = strlen(text);
13   const char* ptr = text + length - 1;
14   while (ptr >= text) {
15     if (strchr(characters, *ptr)) {
16       return ptr;
17     }
18     --ptr;
19   }
20   return nullptr;
21 }
22 
FindLastNotOf(const char * text,const char * characters)23 const char* FindLastNotOf(const char* text, const char* characters) {
24   size_t length = strlen(text);
25   const char* ptr = text + length - 1;
26   while (ptr >= text) {
27     if (!strchr(characters, *ptr)) {
28       return ptr;
29     }
30     --ptr;
31   }
32   return nullptr;
33 }
34 
35 }  // namespace partition_alloc::internal::base::strings
36