source: XIOS/dev/branch_openmp/src/string_tools.hpp @ 1643

Last change on this file since 1643 was 1643, checked in by yushan, 3 years ago

dev on ADA. add new files

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.