From 0cf84e1f006988c114bdca36715d3a2c0601a7d5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 30 Aug 2017 10:23:06 +0300 Subject: Generalize regex_replace_ex() function --- libbutl/regex.ixx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 libbutl/regex.ixx (limited to 'libbutl/regex.ixx') diff --git a/libbutl/regex.ixx b/libbutl/regex.ixx new file mode 100644 index 0000000..dd3ad1d --- /dev/null +++ b/libbutl/regex.ixx @@ -0,0 +1,27 @@ +// file : libbutl/regex.ixx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include // move(), make_pair() + +namespace butl +{ + template + inline std::pair, bool> + regex_replace_ex (const std::basic_string& s, + const std::basic_regex& re, + const std::basic_string& fmt, + std::regex_constants::match_flag_type flags) + { + using namespace std; + + using it = typename basic_string::const_iterator; + + basic_string r; + bool match (regex_replace_ex (s, re, fmt, + [&r] (it b, it e) {r.append (b, e);}, + flags)); + + return make_pair (move (r), match); + } +} -- cgit v1.1