RegexUtils.hpp 682 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-18
  6. * Changed: 2022-07-02
  7. *
  8. * */
  9. #ifndef LS_STD_REGEX_UTILS_HPP
  10. #define LS_STD_REGEX_UTILS_HPP
  11. #include <string>
  12. #include <regex>
  13. namespace ls::std::core
  14. {
  15. class RegexUtils
  16. {
  17. public:
  18. RegexUtils() = default;
  19. ~RegexUtils() = default;
  20. static ::std::string escapeString(const ::std::string &_text)
  21. {
  22. static ::std::regex regexMetaEscape(R"(([\^\$\\\.\*\+\?\(\)\[\]\{\}\|]))");
  23. return ::std::regex_replace(_text, regexMetaEscape, R"(\$1)");
  24. }
  25. };
  26. }
  27. #endif