By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Are you attempting to do something similar to this:

#include <stdio.h>
#include <stdlib.h>
#include <regex.h>

main()
{
     regex_t findDate;
     char *pattern = "[0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9][0-9][0-9]";
     char *string = "Today is 25 Apr 2009";
     char buf[256];
     regmatch_t pmatch[100];
     int status, eflag;

     /* Compile the pattern */

     if ((status = regcomp (&findDate, pattern, REG_EXTENDED)) != 0){
          printf("Unable to compile pattern!\n");
          exit(2);
     }

     eflag = 0;

     /* Extract all matches */

     while ( status = regexec(&findDate,string,1,pmatch,eflag) == 0) {
          printf("Date found: %s\n", string + pmatch[0].rm_so);
          string += pmatch[0].rm_eo;
          eflag = REG_NOTBOL;
     }
     regfree (&findDate);
}

Output:

Date found: 25 Apr 2009

 

Slightly modified from example found here:

http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.nls/doc/nlsgdrf/internationalized_reg_expression_subr.htm