diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-19 15:30:22 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-19 15:30:22 +0300 |
commit | 06e915be138b0638e30083f84cecda0eb1bfc895 (patch) | |
tree | 50f7eca40de25033116c6f6f75524ae5801dcc78 /libbutl/regex.mxx | |
parent | 338d8065f1b681da841fa0d79cc9265776ff1e1e (diff) |
Add regex_replace_match() and rename regex_replace_ex() to regex_replace_search()
Diffstat (limited to 'libbutl/regex.mxx')
-rw-r--r-- | libbutl/regex.mxx | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/libbutl/regex.mxx b/libbutl/regex.mxx index 741b818..7fa0155 100644 --- a/libbutl/regex.mxx +++ b/libbutl/regex.mxx @@ -40,16 +40,9 @@ import std.regex; // @@ MOD TODO should probably be re-exported. LIBBUTL_MODEXPORT namespace butl { - // Call specified append() function for non-matched substrings and matched - // substring replacements returning true if search succeeded. The function - // must be callable with the following signature: - // - // void - // append(basic_string<C>::iterator begin, basic_string<C>::iterator end); - // - // The regex semantics is like that of std::regex_replace() extended the - // standard ECMA-262 substitution escape sequences with a subset of Perl - // sequences: + // The regex semantics for the following functions is like that of + // std::regex_replace() extended the standard ECMA-262 substitution escape + // sequences with a subset of Perl sequences: // // \\, \u, \l, \U, \L, \E, \1, ..., \9 // @@ -65,14 +58,22 @@ LIBBUTL_MODEXPORT namespace butl // C++ locale (which is, unless changed, is the same as C locale and // both default to the POSIX locale aka "C"). // + + // Call specified append() function for non-matched substrings and matched + // substring replacements returning true if search succeeded. The function + // must be callable with the following signature: + // + // void + // append(basic_string<C>::iterator begin, basic_string<C>::iterator end); + // template <typename C, typename F> bool - regex_replace_ex (const std::basic_string<C>&, - const std::basic_regex<C>&, - const std::basic_string<C>& fmt, - F&& append, - std::regex_constants::match_flag_type = - std::regex_constants::match_default); + regex_replace_search (const std::basic_string<C>&, + const std::basic_regex<C>&, + const std::basic_string<C>& fmt, + F&& append, + std::regex_constants::match_flag_type = + std::regex_constants::match_default); // As above but concatenate non-matched substrings and matched substring // replacements into a string returning it as well as whether the search @@ -80,11 +81,19 @@ LIBBUTL_MODEXPORT namespace butl // template <typename C> std::pair<std::basic_string<C>, bool> - regex_replace_ex (const std::basic_string<C>&, - const std::basic_regex<C>&, - const std::basic_string<C>& fmt, - std::regex_constants::match_flag_type = - std::regex_constants::match_default); + regex_replace_search (const std::basic_string<C>&, + const std::basic_regex<C>&, + const std::basic_string<C>& fmt, + std::regex_constants::match_flag_type = + std::regex_constants::match_default); + + // Match the entire string and, if it matches, return the string replacement. + // + template <typename C> + std::pair<std::basic_string<C>, bool> + regex_replace_match (const std::basic_string<C>&, + const std::basic_regex<C>&, + const std::basic_string<C>& fmt); } LIBBUTL_MODEXPORT namespace std |