aboutsummaryrefslogtreecommitdiff
path: root/libbutl/regex.ixx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-08-30 10:23:06 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-08-30 20:57:48 +0300
commit0cf84e1f006988c114bdca36715d3a2c0601a7d5 (patch)
tree8f372d93ac2ed9bde3b57e1e4efe440b3d86d056 /libbutl/regex.ixx
parentc9a062d44807803f1cdfcfe62d49ad1f18162baa (diff)
Generalize regex_replace_ex() function
Diffstat (limited to 'libbutl/regex.ixx')
-rw-r--r--libbutl/regex.ixx27
1 files changed, 27 insertions, 0 deletions
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 <utility> // move(), make_pair()
+
+namespace butl
+{
+ template <typename C>
+ inline std::pair<std::basic_string<C>, bool>
+ regex_replace_ex (const std::basic_string<C>& s,
+ const std::basic_regex<C>& re,
+ const std::basic_string<C>& fmt,
+ std::regex_constants::match_flag_type flags)
+ {
+ using namespace std;
+
+ using it = typename basic_string<C>::const_iterator;
+
+ basic_string<C> 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);
+ }
+}