Opened 13 years ago
Closed 13 years ago
#3389 closed Feature Requests (wontfix)
Replacement format operator to substitute sequential numbers
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | regex |
Version: | Boost 1.40.0 | Severity: | Not Applicable |
Keywords: | regex format syntax | Cc: |
Description
I'd like to suggest an enhancement to the Boost-Extended format string syntax. Its syntax is one of:
\i \i(n)
The former substitutes sequential numbers, starting at 1, while the (n) modifier starts the sequence at value <n>. For example, given this text:
#define FOO 52 #define BAR 53
Searching for "[0-9]+" and replacing with "\i(100)" would result in:
#define FOO 100 #define BAR 101
Each \i in the replacement format is treated independently, so searching for ". ." in the following text:
a b c d
and replacing it with "\i \i(20)" would result in:
1 20 2 21
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.
Thanks
Change History (4)
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
Keith,
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 :-(
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.
HTH, John.
comment:3 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:4 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
(In [57254]) Fixes #3389. Updated and regenerated docs.