Commit 7c36a903f9fb807c9e591852e939fb6efece9b6b

Authored by Jordi Inglada
1 parent d73dd2ea
Exists in master

string::contains

Showing 1 changed file with 13 additions and 0 deletions   Show diff stats
include/cbutils.h
... ... @@ -53,6 +53,19 @@ std::string join(const std::vector<std::string>& vos, char sep=' ')
53 53 }
54 54 return ss.str();
55 55 }
  56 +// True if the string contains one of the patterns
  57 +bool contains(std::string s, std::vector<std::string> patterns)
  58 +{
  59 + bool result{false};
  60 + for(const auto& pat : patterns)
  61 + {
  62 + if(s.find(pat) != std::string::npos)
  63 + {
  64 + return true;
  65 + }
  66 + }
  67 + return result;
  68 +}
56 69 } //end ns string
57 70 // ----------------- System calls ----------------------------------------------
58 71 namespace system{
... ...