Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with Qt and boost::regex

0 views
Skip to first unread message

magnus....@gmail.com

unread,
May 8, 2009, 4:12:51 AM5/8/09
to
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::Dirs,
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;
}
}
}

0 new messages