admin
2024-05-17 56092db23f41123e2d24c7a1d79608d663297733
common/StringUtil.h
@@ -6,6 +6,7 @@
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
using namespace std;
class StringUtil {
@@ -65,4 +66,22 @@
      oss << std::fixed << std::setprecision(precision) << value;
      return oss.str();
   }
   static std::vector<std::string> split(std::string str, std::string pattern) {
      std::string::size_type pos;
      std::vector<std::string> result;
      str += pattern;//扩展字符串以方便操作
      int size = str.size();
      for (int i = 0; i < size; i++)
      {
         pos = str.find(pattern, i);
         if (pos < size)
         {
            std::string s = str.substr(i, pos - i);
            result.push_back(s);
            i = pos + pattern.size() - 1;
         }
      }
      return result;
   }
};