[pcre-dev] [Bug 2511] New: Feature Request: PCRE2_SUBSTITUTE…

Startseite
Nachricht löschen
Autor: admin
Datum:  
To: pcre-dev
Betreff: [pcre-dev] [Bug 2511] New: Feature Request: PCRE2_SUBSTITUTE, option for getting *just* the replacement of a single match
https://bugs.exim.org/show_bug.cgi?id=2511

            Bug ID: 2511
           Summary: Feature Request: PCRE2_SUBSTITUTE, option for getting
                    *just* the replacement of a single match
           Product: PCRE
           Version: 10.34 (PCRE2)
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: ph10@???
          Reporter: kkilger@???
                CC: pcre-dev@???


Hi,

this as an extension to my bug 2488, which you already implemented, as I have
seen just today.

The function pcre2_substitute would be much more versatile, if it would be
possible to just "calculate" a single match/replacement, without doing the
actual replacement in the original string.

As an example I am referring to other libraries, e.g. boost/C++
boost::regex_format function (or its successors), see here:

https://www.boost.org/doc/libs/1_61_0/libs/regex/doc/html/boost_regex/ref/deprecated_interfaces/regex_format.html

A first step in this direction was bug 2488, i.e. reusing an existing match.
What is missing is to omit to copy the string before and after the match. As a
hack I implemented another option to achieve this: PCRE2_SUBSITUTE_MATCH_ONLY.

By using PCRE2_SUBSTITUTE_MATCHED and PCRE2_SUBSTITUTE_MATCH_ONLY, I can, if I
don't set the PCRE2_SUBSTITUTE_GLOBAL simulate something like
boost::regex_format.

However the semantics is kind of weird (especially as I *can* set
PCRE2_SUBSTITUTE_GLOBAL) and my feeling is, that, API-wise, a specialized
function like pcre2_substitute_match which just calculates the replacement
string for a single match (given a already valid match) would be better.

What is you opinion?

--
You are receiving this mail because:
You are on the CC list for the bug.