blob: 17f0cd09baa3aa4af6f2f7585965e2a57bfec35a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// file : CCF/CodeGenerationKit/Regex.hpp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $Id$
#ifndef CCF_RUNTIME_REGEX_HPP
#define CCF_RUNTIME_REGEX_HPP
#include <string>
#include <boost/regex.hpp>
namespace regex
{
using boost::regex;
using boost::regex_merge;
inline std::string
perl_s (std::string src, std::string e, char delimiter = '/')
{
std::string::size_type first = e.find (delimiter);
std::string::size_type middle = e.find (delimiter, first + 1);
std::string::size_type last = e.find (delimiter, middle + 1);
std::string pattern (e, first + 1, middle - first - 1);
std::string format (e, middle + 1, last - middle - 1);
//std::cout << pattern << " " << format << std::endl;
regex expr (pattern);
return regex_merge (
src,
expr,
format,
boost::match_default | boost::format_all );
}
}
#endif // CCF_RUNTIME_REGEX_HPP
|