1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
regex_t kanpiljat; int rc; size_t nmatch = 2; regmatch_t ptr_match[3]; if (0 != (rc = regcomp(&kanpiljat, suchmaske.c_str(), REG_EXTENDED))) { // "regcomp() failed, returning nonzero (%d)\n", rc exit(EXIT_FAILURE); } if (0 != (rc = regexec(&kanpiljat, text.c_str(), nmatch, ptr_match, 0))) { // "Failed to match '%s' with '%s',returning %d.\n", text, pattern, rc } else { result = text.SubString(ptr_match[1].rm_so+1, ptr_match[1].rm_eo - ptr_match[1].rm_so); } regfree(&kanpiljat); return 1; } |