S
S
Sergey Savostin2011-07-03 01:00:12
recursion
Sergey Savostin, 2011-07-03 01:00:12

[boost::xpressive] Multipass swap?

Plz tell me who is in the know, otherwise the whole Google has already broken.
There is a line in which boost::xpressive replaces one with the other, but the result is the same string, which must also be replaced (oh, how I said!).
Example:

sregex tmp = sregex::compile( &quot;([0-9]+)\\-([0-9]+)&quot;);<br/>
string t = regex_replace(string(&quot;8-8-8-8&quot;), tmp, string(&quot;$1&quot;), regex_constants::format_perl);<br/>

The result is “8-8”, but I want 8.
Maybe there is some key / parameter?
Of course, you can “recursively / in a loop”, but how then to determine that there was no replacement? It would not be desirable to compare lines before and after.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kindman, 2011-07-07
@Kindman

>> Не хочется же строки до и после сравнивать.
It's strange, but I had exactly such an idea (compare before and after), while reading the question (until I read this last line).
If you do not want to compare the strings themselves, you can compare the hashes of these strings, for example md5 or sha1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question