From Queen Dove, 4 Years ago, written in C.
Embed
  1. #define _GNU_SOURCE
  2.  
  3. #include <regex.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. // http://stackoverflow.com/questions/2359811/working-with-gnu-regex-functions-in-c-or-c
  8.  
  9. int main() {
  10.    int i;
  11.    char pat_str[] = "\\(.*\\)\\(FS#[0-9]+\\)\\(.*\\)";
  12.    struct re_pattern_buffer pat_buff;
  13.    pat_buff.translate = 0;
  14.    pat_buff.fastmap = 0;
  15.    pat_buff.buffer = 0;
  16.    pat_buff.allocated = 0;
  17.    //pat_buff.syntax = _RE_SYNTAX_POSIX_COMMON;
  18.    re_syntax_options = _RE_SYNTAX_POSIX_COMMON;
  19.  
  20.    re_compile_pattern(pat_str, sizeof(pat_str) - 1, &pat_buff);
  21.    char* strings[] = {"Partially implements FS#6: Conference ID changed to c+bugs@conference.thedevstack.de", "abc\nblubb FS#123 abc", "blubber"};
  22.  
  23.    for (i = 0; i < sizeof(strings)/sizeof(char*); i++) {
  24.       int match_ret = re_match(&pat_buff, strings[i], strlen(strings[i]), 0, NULL);
  25.       if (match_ret >= 0) {
  26.          printf("juhu\n");
  27.       } else if (match_ret == -1) {
  28.          printf("ohno\n");
  29.       } else {
  30.          printf("error\n");
  31.       }
  32.    }
  33.  
  34.    regfree(&pat_buff);
  35. }
  36.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Corrupt Pintail c 4 Years ago.