source: XIOS/dev/dev_olga/src/string_tools.hpp @ 1612

Last change on this file since 1612 was 1590, checked in by oabramkina, 5 years ago

Backporting recent changes to dev before merging it to trunk.

File size: 596 bytes
Line 
1#ifndef __STRING_TOOLS_HPP__
2#define __STRING_TOOLS_HPP__
3
4#include <string>
5#include <regex>
6#include <vector>
7
8namespace xios
9{
10  std::vector<std::string> splitRegex(const std::string& input, const std::string& regex) ;
11
12  inline std::vector<std::string> splitRegex(const std::string& input, const std::string& regex)
13  {
14      // passing -1 as the submatch index parameter performs splitting
15      std::regex re(regex);
16      std::regex_token_iterator<std::string::const_iterator>
17          first{input.begin(), input.end(), re, -1},
18          last;
19      return {first, last}; 
20  }
21
22}
23#endif
Note: See TracBrowser for help on using the repository browser.