RegexUtils.hpp 651 B

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