Boost C++ Libraries: Ticket #3389: Replacement format operator to substitute sequential numbers https://svn.boost.org/trac10/ticket/3389 <p> I'd like to suggest an enhancement to the Boost-Extended format string syntax. Its syntax is one of: </p> <pre class="wiki">\i \i(n) </pre><p> The former substitutes sequential numbers, starting at 1, while the (n) modifier starts the sequence at value &lt;n&gt;. For example, given this text: </p> <pre class="wiki">#define FOO 52 #define BAR 53 </pre><p> Searching for "<a class="source" href="https://svn.boost.org/trac10/log/?revs=0-9">[0-9]</a>+" and replacing with "\i(100)" would result in: </p> <pre class="wiki">#define FOO 100 #define BAR 101 </pre><p> Each \i in the replacement format is treated independently, so searching for ". ." in the following text: </p> <pre class="wiki">a b c d </pre><p> and replacing it with "\i \i(20)" would result in: </p> <pre class="wiki">1 20 2 21 </pre><p> A useful variation would be the ability to specify the field width required, perhaps using "\i(n,w)", for leading spaces, and "\i(n,0w)" for leading zeroes. </p> <p> Thanks </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3389 Trac 1.4.3 John Maddock Fri, 30 Oct 2009 18:45:46 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3389#comment:1 https://svn.boost.org/trac10/ticket/3389#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</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/57254" title="Fixes #3389. Updated and regenerated docs.">[57254]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3389" title="#3389: Feature Requests: Replacement format operator to substitute sequential numbers (closed: wontfix)">#3389</a>. Updated and regenerated docs. </p> Ticket John Maddock Fri, 30 Oct 2009 18:51:31 GMT <link>https://svn.boost.org/trac10/ticket/3389#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3389#comment:2</guid> <description> <p> Keith, </p> <p> I think I'm going to close this one as "won't fix" for the following reason: the only place to store the needed state would be in the regular expression object (it's the only object that's persistant between matches), but the regular expression is supposed to be constant and immutable so it can be used from multiple threads simultaniously, so it's realy not a good place to store this :-( </p> <p> That said, I've just added to trunk another feature which may help: regex_replace now allows the format string to be not a string at all, but a function object. So you can now write and supply your own custom functor (with state!) to do the same job. </p> <p> HTH, John. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 30 Oct 2009 18:51:51 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/3389#comment:3 https://svn.boost.org/trac10/ticket/3389#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket John Maddock Fri, 30 Oct 2009 18:52:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3389#comment:4 https://svn.boost.org/trac10/ticket/3389#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket