8 #ifndef SIG_UTIL_REGEX_HPP
9 #define SIG_UTIL_REGEX_HPP
11 #include "../helper/type_convert.hpp"
12 #include "../helper/maybe.hpp"
18 #pragma warning ( disable : 4996 )
21 #if !SIG_MSVC_ENV && SIG_ENABLE_BOOST
22 #include <boost/regex.hpp>
25 #if (__GLIBCXX__ || __GLIBCPP__)
26 #define SIG_USE_GLIBCPP 1
35 #define SIG_RegexSearch std::regex_search
36 #define SIG_RegexReplace std::regex_replace
37 #elif SIG_ENABLE_BOOST
42 #define SIG_RegexSearch boost::regex_search
43 #define SIG_RegexReplace boost::regex_replace
45 #define SIG_REGEX_UNABLE 1
88 inline auto escape_regex(std::string
const& expression) ->std::string
90 static const SIG_Regex escape_reg(R
"(([(){}\[\]|^?$.+*\\]))");
98 inline auto escape_regex(std::wstring
const& expression) ->std::wstring
100 static const SIG_WRegex escape_reg(LR
"(([(){}\[\]|^?$.+*\\]))");
105 #elif (SIG_USE_GLIBCPP && SIG_ENABLE_BOOST)
111 inline auto escape_regex(std::string
const& expression) ->std::string
113 static const SIG_Regex escape_reg(R
"(([(){}\[\]|^?$.+*\\]))");
121 inline auto escape_regex(std::wstring
const& expression) ->std::wstring
123 static const SIG_WRegex escape_reg(LR
"(([(){}\[\]|^?$.+*\\]))");
130 #if SIG_MSVC_ENV || (SIG_USE_GLIBCPP && SIG_ENABLE_BOOST)
171 template <
class S,
class TS = impl::
string_t<S>>
175 ->Maybe<std::vector<std::vector<TS>>>
177 using R = std::vector<std::vector<TS>>;
180 auto tmp =
static_cast<TS
>(src);
184 d.push_back(std::vector<TS>());
185 for (
auto const& m : match) d.back().push_back(m);
186 tmp = match.suffix().str();
189 return d.empty() ?
Nothing(std::move(d)) :
Just(std::move(d));
auto Nothing() -> typename impl::SameIf< T, void, typename boost::none_t, Maybe< T >>::type
値コンストラクタ
Maybe< R > Just(T &&v)
値コンストラクタ
auto make_regex(S const &expression) -> typename impl::Str2RegexSelector< impl::string_t< S >>::regex
エスケープ処理を行い、regexオブジェクトを返す
auto regex_search(S &&src, typename impl::Str2RegexSelector< TS >::regex const &expression) -> Maybe< std::vector< std::vector< TS >>>
std::regex_search のラッパ関数
auto escape_regex(std::string const &expression) -> std::string
与えられた文字中に含まれる、正規表現の特殊文字をエスケープする