Pagini recente » Cod sursa (job #1657225) | Cod sursa (job #1237573) | Cod sursa (job #3166174) | Cod sursa (job #2693585) | Cod sursa (job #23503)
Cod sursa(job #23503)
#include <iostream>
#include <regex>
using namespace std;
string pattern = "([a-z]+).\\1";
string str = "top-topcoder|coder";
re_pattern_buffer buffer;
char map[256];
buffer.translate = 0;
buffer.fastmap = map;
buffer.buffer = 0;
buffer.allocated = 0;
re_set_syntax(RE_SYNTAX_POSIX_EXTENDED);
const char* status = re_compile_pattern(pattern.c_str(),pattern.size(),&buffer);
if (status) {
cout << "Error: " << status << endl;
}
re_compile_fastmap(&buffer);
struct re_registers regs;
int ofs = 0;
if (re_search(&buffer,str.c_str(),str.size(),0,str.size(),®s)!=-1) {
cout << "Match "
cout << str.substr(regs.start[0],regs.end[0]-regs.start[0])
cout << " found starting at: "
cout << regs.start[0]
cout << " and ending at "
cout << regs.end[0]
cout << endl;
} else {
cout << "Match not found."
cout << endl;
}
regfree(&buffer);
int main()
{
return 0;
}