Boost C++ Libraries: Ticket #10383: Wrongly character was replaced when using boost::regex https://svn.boost.org/trac10/ticket/10383 <p> Hi, When I used regex_replace function to replace whitespace character in one string, I found that another character(0xa0 in memory) was also replaced. </p> <p> The follow is my verification code: </p> <p> int main(int argc, _TCHAR* argv[]) { </p> <blockquote> <p> boost::regex whitespace_re("<br />s+"); string instr = "a c d f"; cout &lt;&lt; "Before replace instr:" &lt;&lt; instr &lt;&lt; endl; instr = boost::regex_replace(instr, whitespace_re, "-"); cout &lt;&lt; "After replaced instr: " &lt;&lt; instr &lt;&lt; endl; </p> </blockquote> <blockquote> <p> string instr2 = "abcdef"; instr2<a class="missing changeset" title="No changeset 0 in the repository">[0]</a>= 0xa0; instr2<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">[2]</a>= 0xa0; cout &lt;&lt; "Before replace instr2:" &lt;&lt; instr2 &lt;&lt; endl; instr2 = boost::regex_replace(instr2, whitespace_re, "-"); cout &lt;&lt; "After replaced instr2: " &lt;&lt; instr2 &lt;&lt; endl; return 0; </p> </blockquote> <p> } </p> <p> And the output is attached. Develop Environment: Windows 7 Professional(language is Einglish U.S.), VS2005. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10383 Trac 1.4.3 tamber@… Wed, 20 Aug 2014 09:49:54 GMT attachment set https://svn.boost.org/trac10/ticket/10383 https://svn.boost.org/trac10/ticket/10383 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Untitled.png</span> </li> </ul> <p> output of verification code </p> Ticket John Maddock Wed, 20 Aug 2014 17:44:41 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10383#comment:1 https://svn.boost.org/trac10/ticket/10383#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">invalid</span> </li> </ul> <p> That's correct behaviour: character 0xA0 is a "non-breaking space" and therefore correctly replaced in your test case. </p> Ticket