Improved regex to correctly match quoted characters in strings

master
Marius Kintel 2014-12-16 13:03:12 -05:00
parent 14870d69de
commit 77c865d1be
1 changed files with 1 additions and 1 deletions

View File

@ -49,7 +49,7 @@ const std::string &Tree::getIdString(const AbstractNode &node) const
assert(this->root_node);
if (!this->nodeidcache.contains(node)) {
const std::string &str = getString(node);
const boost::regex re("(\".*\")|\\S+");
const boost::regex re("[^\\s\\\"]+|\\\"(?:[^\\\"\\\\]|\\\\.)*\\\"");
std::stringstream sstream;
boost::sregex_token_iterator i(str.begin(), str.end(), re, 0);
std::copy(i, boost::sregex_token_iterator(), std::ostream_iterator<std::string>(sstream));