Fix pcre_exec matched string

This commit is contained in:
Felipe Zimmerle 2015-10-16 16:15:39 -03:00
parent 0285c944f9
commit c800214e6d
2 changed files with 9 additions and 3 deletions

View File

@ -30,8 +30,7 @@ bool Rx::evaluate(Assay *assay, const std::string& input) {
SMatch match;
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
std::cout << "wheee" << std::endl;
// this->matched.push_back(match.match);
this->matched.push_back(match.match);
return true;
}

View File

@ -48,8 +48,15 @@ Regex::Regex(const std::string& pattern_)
int regex_search(const std::string& s, SMatch *match,
const Regex& regex) {
int ovector[OVECCOUNT];
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
int ret = pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
if (ret > 0) {
match->match = std::string(s, ovector[2], ovector[3] - ovector[2]);
match->size_ = ret;
}
return ret;
}
int regex_search(const std::string& s, const Regex& regex) {