#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <pcre.h>
using namespace std;
int main()
{
fstream file_buff;
file_buff.open("file",ios::in );
string buffer;
file_buff >>buffer;
char regx[] = "\w+.\/\/\w+\d+\.\w+\.\w+\/\w+-.+\.\w";
pcre *re;
int options = 0;
const char *error;
int erroffset;
re = pcre_compile (regx, options, &error, &erroffset, NULL);
if (!re)
{
cout << "Failed\n";
}
else
{
int count = 0;
int ovector[30];
cout << "Парсинг... " << endl;
count = pcre_exec (re, NULL, buffer.c_str(),buffer.length(), 0, 0, ovector, 30);
if (count< 0)
{
switch(count)
{
case PCRE_ERROR_NOMATCH:
cout << "Нет совпадений" << endl;
return -1;
default:
cout << "Ошибка : " <<count <<endl;
return -1;
}
free(re); /* Release memory used for the compiled pattern */
return 1;
}
else
{
for (int c = 0; c < 2 * count; c += 2)
{
if (ovector[c] < 0)
{
cout << "\n";
}
else
{
cout << ovector[c] << "/" << ovector[c + 1] << "\n";
}
}
}
}
return 0;
}
$ g++ -lpcre -o t t.cpp
$ ./t
Парсинг...
9782/9914
http://fileshare245.depositfiles.com/auth-1261655739bede5d845b7b1f335a0176-95.158.205.93-969473376-34511674-guest/FS245-8/x_zone.rar
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.