split_by_regex.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <regex>
3 #include <string>
4 #include <vector>
5 
6 namespace cet {
7  std::vector<std::string>
8  split_by_regex(std::string const& str, std::regex const& reDelimSet)
9  {
10  std::vector<std::string> tokens;
11  std::copy(
12  std::sregex_token_iterator(str.begin(), str.end(), reDelimSet, -1),
13  std::sregex_token_iterator{},
14  std::back_inserter(tokens));
15  return tokens;
16  }
17 
18  std::vector<std::string>
19  split_by_regex(std::string const& str, std::string const& delimSet)
20  {
21  std::regex const tmpRegex{delimSet};
22  return split_by_regex(str, tmpRegex);
23  }
24 }
std::string string
Definition: nybbler.cc:12
std::vector< std::string > split_by_regex(std::string const &str, std::regex const &reDelimSet)
T copy(T const &v)
static QCString str