Opened 5 years ago
#13232 new Feature Requests
u32regex_replace - None of these prototypes have callback formatter capability
| Reported by: | Owned by: | John Maddock | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | regex |
| Version: | Boost 1.65.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
I've had to do a workaround using a u32regex_iterator.
This one takes parameters wstring, u32regex, and function address.
(Internally it converts the wstring to u32string and does
the replacement with the user callback).
I just have to add more prototypes for the different forms
needed, but it would be nice if I didn't have to do this.
void U_Regex_Replace_Callback(
X_string& strSrc,
U_X_regex& Rx,
X_32string (*func)(X_u32smatch) )
{
X_32string str32Src, str32Repl, str32Out;
WstrToU32string( strSrc, str32Src );
str32Out.clear();
boost::u32regex_iterator<std::u32string::const_iterator>
i(boost::make_u32regex_iterator( str32Src, Rx)), j;
U32SITR last = str32Src.begin();
while(i != j)
{
str32Out.append( (*i).prefix() );
str32Out.append( func( (*i) ) ) ;
last = (*i)[0].second;
++i;
}
str32Out.append( last, str32Src.end() );
U32stringToWstr( str32Out, strSrc );
}
Note:
See TracTickets
for help on using tickets.
