split_by_regex.h
Go to the documentation of this file.
1 #ifndef cetlib_split_by_regex_h
2 #define cetlib_split_by_regex_h
3 
4 // ======================================================================
5 //
6 // split_by_regex: Obtain substrings at a string's specified boundaries,
7 // defined according to a regex delimiter set.
8 //
9 // This is a high-powered method of tokenizing that uses
10 // the C++ regex library to split into substrings.
11 //
12 // Examples of splitting with ":" as the separator:
13 // input result
14 // "" [""] # Different behavior than split.h
15 // "a" ["a"]
16 // "a:" ["a"]
17 // ":boo" ["","boo"] # Different behavior than split.h
18 // "a:b" ["a","b"]
19 // "a::b" ["a","","b"] # Different behavior than split.h
20 //
21 // More complicated example splitting by "::" and "().":
22 //
23 // split_by_regex( "namespace::class::static_function().value",
24 // "(::|\\(\\)\\.)" )
25 //
26 // returns ["namespace","class","static_function","value"]
27 //
28 // ======================================================================
29 
30 #include <string>
31 #include <vector>
32 
33 namespace cet {
34 
35  std::vector<std::string> split_by_regex(std::string const& str,
36  std::string const& delimSet);
37 }
38 
39 #endif /* cetlib_split_by_regex_h */
40 
41 // Local variables:
42 // mode: c++
43 // End:
std::vector< std::string > split_by_regex(std::string const &str, std::string const &delimSet)
enum BeamMode string