Opened 8 years ago
Closed 8 years ago
#10383 closed Bugs (invalid)
Wrongly character was replaced when using boost::regex
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | regex |
Version: | Boost 1.48.0 | Severity: | Problem |
Keywords: | regex replace | Cc: |
Description
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.
The follow is my verification code:
int main(int argc, _TCHAR* argv[]) {
boost::regex whitespace_re("
s+"); string instr = "a c d f"; cout << "Before replace instr:" << instr << endl; instr = boost::regex_replace(instr, whitespace_re, "-"); cout << "After replaced instr: " << instr << endl;
string instr2 = "abcdef"; instr2[0]= 0xa0; instr2[2]= 0xa0; cout << "Before replace instr2:" << instr2 << endl; instr2 = boost::regex_replace(instr2, whitespace_re, "-"); cout << "After replaced instr2: " << instr2 << endl; return 0;
}
And the output is attached. Develop Environment: Windows 7 Professional(language is Einglish U.S.), VS2005.
Attachments (1)
Change History (2)
by , 8 years ago
Attachment: | Untitled.png added |
---|
comment:1 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
That's correct behaviour: character 0xA0 is a "non-breaking space" and therefore correctly replaced in your test case.
output of verification code