#include "main.h"
bool easyRegex(std::string sString, boost::regex rRegex, boost::smatch &sResults, int iArg, char *szRegexName)
{
if (boost::regex_search(sString, sResults, rRegex))
{
if (sResults.size() < iArg)
{
printf("Error %s! | Size: %d < %d\n", szRegexName, sResults.size(), iArg);
return false;
}
printf("[easyRegex] Pointer: %p\n", sResults);
printf("[easyRegex] Size: %d\n", sResults.size());
for (int i = 1; i < sResults.size(); i++)
printf("[easyRegex] [%d] %s\n", i, sResults.str(i).c_str());
return true;
}
else
{
printf("Error %s! | regex_search\n", szRegexName);
return false;
}
}
int main()
{
std::cout << "Hello!\n";
std::string sTest = "sdf 24 string 3452 43556aad";
boost::regex regex("\\w+ ([\\d]+) ([\\w]+) ([\\d]+) ([\\d\\w]+)");
boost::smatch result;
if (easyRegex(sTest, regex, result, 5, "test"))
{
printf("[main] Pointer: %p\n", result);
printf("[main] Size: %d\n", result.size());
for (int i = 1; i < result.size(); i++)
printf("[main] [%d] %s\n", i, result.str(i).c_str());
}
system("pause");
}