#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main()
{
std::string tmpStr= "192.168.0.1";
boost::regex expression("([0-9]+).([0-9]+).([0-9]+)");
boost::smatch what;
if(boost::regex_search(tmpStr, what, expression))
{
std::cout << what.size() << std::endl;
for(size_t i = 0; i < what.size(); i++)
{
if(what[i].matched)
{
std::cout << what[i] << std::endl;
}
}
}
return 0;
}
Makefile
INC_DIR=-I/usr/include/
LIB_DIR=-L/usr/lib64/
LIB=-lboost_regex
CC=g++ -g
CFLAGS=-Wall
EXE=test
all:
$(CC) $(CFLAGS) $(EXE).cpp -o $(EXE) $(INC_DIR) $(LIB_DIR) $(LIB)
clean:
rm -rf *.o $(EXE)