So i'm trying to make a program that searches for the number of <nodes in a file using regex_match. I've jumped through all the hoops but nothing seems to turn up a match.
string str;
int numNodes = 0;
ifstream infile("map1.osm");
if(infile.is_open())
{
regex node("^ <node .+ .+ .+ .+ .+ .+ .+ .+ .+>$");
while(getline(infile, str, '\n'))
{
cout << str << endl;
if(regex_match(str, node))
{
numNodes++;
}
}
cout << numNodes << endl;
}
infile.close();
The line's format that I'm trying to match is like this
<node id="38904495" visible="true" version="2" changeset="7460681" timestamp="2011-03-05T08:22:09Z" user="v12mike" uid="96640" lat="52.1823213" lon="-0.1499624"/>
If regex_match finds a match, it should increase numNodes by 1. At the end it always prints out 0.