I slightly modified Ferruccio's solution to also eliminate other characters that are in the way, like 0x20, etc. (Located somewhere on the Internet). Tested and working.
void strip_tags(string* s) { regex kj("</?(.*)>"); *s = regex_replace(*s, kj, "", boost::format_all); std::map<char, std::string> transformations; transformations['&'] = std::string("& "); transformations['\''] = std::string("' "); transformations['"'] = std::string("" "); transformations['>'] = std::string("> "); transformations['<'] = std::string("< ");
So, in this case there are two functions. We can get the result with something like:
string StartingString ("Some_value"); string FinalString = removeTroublesomeCharacters(strip_tags(&StartingString));
Hope this helps!
(Oh yes: credit for another function is provided to the author of the answer here: How to remove invalid hexadecimal characters from an XML-based data source before creating an XmlReader or XPathDocument that uses the data? )
Tex May 11 '12 at 14:18 2012-05-11 14:18
source share