From 81023bbde2d70d8ecf0a3599d0586acf42628a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20L=C3=BCke?= Date: Fri, 27 Dec 2024 14:37:11 +0100 Subject: [PATCH] add split_string() utility --- include/mesytec-mnode/mnode_string.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 include/mesytec-mnode/mnode_string.hpp diff --git a/include/mesytec-mnode/mnode_string.hpp b/include/mesytec-mnode/mnode_string.hpp new file mode 100644 index 0000000..31af9dd --- /dev/null +++ b/include/mesytec-mnode/mnode_string.hpp @@ -0,0 +1,19 @@ +#ifndef E7FD4517_4FF5_4BDA_9AE4_95308A37554D +#define E7FD4517_4FF5_4BDA_9AE4_95308A37554D + +#include +#include + +namespace mesytec::mnode +{ + +template +void split_string(const std::string &str, const std::regex &re, OutputIt out) +{ + std::sregex_token_iterator it(str.begin(), str.end(), re, -1); + std::copy(it, std::sregex_token_iterator(), out); +} + +} // namespace mesytec::mnode + +#endif /* E7FD4517_4FF5_4BDA_9AE4_95308A37554D */