Boost C++ Libraries: Ticket #2556: Perl regex replacement https://svn.boost.org/trac10/ticket/2556 <p> I have code that reads a lookup table from memory and then attempts to search for the word found in the lookup table in some data using a regular expression:- </p> <p> (.*\b)word(\b.*) </p> <p> Where this matches I call replace with the following </p> <p> $1WORD$2 </p> <p> This falls down when the word is "2lt" as I get the following to search for </p> <p> (.*\b)2lt(\b.*) </p> <p> With replacement </p> <p> $12LT$2 </p> <p> What happens is it sees $12 as the substring to replace and since I only have two pairs of brackets in my regular expression $12 does not exist and so in effect the 2 in my input data is lost. </p> <p> I am using Perl format regular expressions (boost::regex::perl) </p> <p> In Perl I can resolve this by making the replacement </p> <p> $<a class="report" href="https://svn.boost.org/trac10/report/1">{1}</a>2LT$<a class="report" href="https://svn.boost.org/trac10/report/2">{2}</a> </p> <p> When I do this using boost I get the literal text as above output (including $<a class="report" href="https://svn.boost.org/trac10/report/1">{1}</a> etc.) not the text that I expect. Since I've told Boost to use Perl syntax I would expect a regular expression replacement in Perl and Boost to behave the same way. </p> <p> Is this a bug ? </p> <p> Thanks Jon </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2556 Trac 1.4.3 John Maddock Mon, 01 Dec 2008 16:46:42 GMT status changed https://svn.boost.org/trac10/ticket/2556#comment:1 https://svn.boost.org/trac10/ticket/2556#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Looks like a bug, or at least a missing feature. </p> <p> Will fix. </p> <p> John Maddock. </p> Ticket John Maddock Tue, 23 Dec 2008 11:46:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2556#comment:2 https://svn.boost.org/trac10/ticket/2556#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/50370" title="Fix gcc warnings from ICU wrappers. Add optional support for marked ...">[50370]</a>) Fix gcc warnings from ICU wrappers. Add optional support for marked sub-expression location information. Add support for ${n} in format replacement text. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2556" title="#2556: Bugs: Perl regex replacement (closed: fixed)">#2556</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2269" title="#2269: Library Submissions: Regex marked parenthesis fetching (closed: fixed)">#2269</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2514" title="#2514: Bugs: Warnings for unicode regex includes (closed: fixed)">#2514</a>. </p> Ticket