blob: 6a5dbd35978fa9eacab39829ebd89ad88d8089fb (
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
|
#pragma once
#include <boost/xpressive/xpressive.hpp>
#include <boost/xpressive/regex_token_iterator.hpp>
namespace regexp
{
typedef boost::xpressive::sregex RegExpT;
inline void Create(string const & regexp, RegExpT & out)
{
out = RegExpT::compile(regexp);
}
inline bool Matches(string const & str, RegExpT const & regexp)
{
return boost::xpressive::regex_match(str, regexp);
}
inline bool IsExist(string const & str, RegExpT const & regexp)
{
return boost::xpressive::regex_search(str, regexp);
}
template <class FnT> void ForEachMatched(string const & str, RegExpT const & regexp, FnT fn)
{
typedef boost::xpressive::sregex_token_iterator IterT;
IterT i(str.begin(), str.end(), regexp);
IterT end;
for (; i != end; ++i)
fn(*i);
}
}
|