1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Rep Power

    How to regex_t variable in a map?


    I am trying to create a map in C++ which will have the regular expression and the corresponding compiled regular form returned by regcomp. It will be something like this:

    map <string, regex_t> my_var;

    In the startup process we read the regular expressions and store corresponding regex_t variable value in the map. regex_t variable is something like this:

    regex_t re;
    reslt = regcomp(&re, regex_string, REG_EXTENDED|REG_NOSUB);

    then we do:


    In other file we use this map to read the re and pass it on to regexec.

    It compiles well. But on running we get coredump.

    We are yet to call regfree in the startup process to free memory allocated by regcomp. I guess issues will be there also since it did not work in my test program. Good old segmentation fault.

    Read somewhere on the net that we cant copy regex_t since its an opaque and cant just copy it.

    Any suggestions friends?
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Rep Power
    What is your regex question?

IMN logo majestic logo threadwatch logo seochat tools logo