M
magnus.moraberg
The following code is not working as I expect it. The output for this
code is -
0
1
2
Found: Case_v73
If I replace:
boost::regex_match(directoryList.at(i).toStdString(), matches, pat)
with:
boost::regex_match(x, matches, pat)
I get the expected output:
0 Case_v73
1 Case
2 73
Found: Case_v73
How come?
toStdString() returns an object of type std::string.
Thanks,
Magnus
LocalCaseList::LocalCaseList(const QDir& caseDirectory)
: caseDirectory(caseDirectory)
{
QStringList directoryList = caseDirectory.entryList(QDir:irs,
QDir::Name);
for (int i = 0; i < directoryList.size(); i++)
{
boost::regex pat( "^(.+)_v([0-9]+)$" );
boost::smatch matches;
std::string x = directoryList.at(i).toStdString();
if (boost::regex_match(directoryList.at(i).toStdString(),
matches, pat))
{
for(int j = 0; j < matches.size(); j++)
std::cout << j <<matches[j]<< std::endl;
std::cout << "Found: " << directoryList.at(i).toStdString() <<
std::endl;
}
}
}
code is -
0
1
2
Found: Case_v73
If I replace:
boost::regex_match(directoryList.at(i).toStdString(), matches, pat)
with:
boost::regex_match(x, matches, pat)
I get the expected output:
0 Case_v73
1 Case
2 73
Found: Case_v73
How come?
toStdString() returns an object of type std::string.
Thanks,
Magnus
LocalCaseList::LocalCaseList(const QDir& caseDirectory)
: caseDirectory(caseDirectory)
{
QStringList directoryList = caseDirectory.entryList(QDir:irs,
QDir::Name);
for (int i = 0; i < directoryList.size(); i++)
{
boost::regex pat( "^(.+)_v([0-9]+)$" );
boost::smatch matches;
std::string x = directoryList.at(i).toStdString();
if (boost::regex_match(directoryList.at(i).toStdString(),
matches, pat))
{
for(int j = 0; j < matches.size(); j++)
std::cout << j <<matches[j]<< std::endl;
std::cout << "Found: " << directoryList.at(i).toStdString() <<
std::endl;
}
}
}