I was trying to do a regex replace with boost::regex, but it doesn't seem to be working.
Here is the regex expression:
(\\w+,\\d+,\\d+,\\d+\tscript\t)(.+)(#)(.+)(\t\\d+(,\\d+)?(,\\d+)?,{)
And the formatter:
$1\"$2\"$3\"$4\"$5
The code: (getInput() returns a string with content that should match)
std::string &Preprocessor::preprocess()
{
std::string &tempString = getInput();
boost::regex scriptRegexFullName;
const char *scriptRegexFullNameReplace = "$1\"$2\"$3\"$4\"$5";
scriptRegexFullName.assign("(\\w+,\\d+,\\d+,\\d+\tscript\t)(.+)(#)(.+)(\t\\d+(,\\d+)?(,\\d+)?,{)");
tempString = boost::regex_replace(tempString, scriptRegexFullName, scriptRegexFullNameReplace, boost::match_default);
return tempString;
}
When I put the following test cases on this website:
alberta,246,82,3 script Marinheiro#bra2 100,{
brasilis,316,57,3 script Marinheiro#bra1 100,{
brasilis,155,165,3 script Orientação divina#bra1 858,{
The output of the website is correct:
alberta,246,82,3 script "Marinheiro"#"bra2" 100,{
brasilis,316,57,3 script "Marinheiro"#"bra1" 100,{
brasilis,155,165,3 script "Orientação divina"#"bra1" 858,{
But with boost::regex the output is:
alberta,246,82,3 script "Marinheiro#bra2 100,{
brasilis,316,57,3 script Marinheiro#bra1 100,{
brasilis,155,165,3 script Orientação divina#bra1 858,{
What am I doing wrong, anyone knows?
Thanks for the help.