diff options
Diffstat (limited to 'src/regmatch.cc')
-rw-r--r-- | src/regmatch.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/regmatch.cc b/src/regmatch.cc new file mode 100644 index 0000000..c433087 --- /dev/null +++ b/src/regmatch.cc @@ -0,0 +1,31 @@ +/** -------------------------------------------------------------------- + * @file regex.cc + * @brief Implementation of miscellaneous regexp functions + * @author Andreas Aardal Hanssen + * @date 2002-2005 + * ----------------------------------------------------------------- **/ +#include "regmatch.h" +#include <string> + +#include <sys/types.h> +#include <regex.h> +#include <stdio.h> + +using namespace ::std; + +//------------------------------------------------------------------------ +int Binc::regexMatch(const string &data_in, const string &p_in) +{ + regex_t r; + regmatch_t rm[2]; + + if (regcomp(&r, p_in.c_str(), REG_EXTENDED | REG_NOSUB) != 0) + return 2; + + int n = regexec(&r, data_in.c_str(), data_in.length(), rm, 0); + regfree(&r); + if (n == 0) + return 0; + else + return 2; +} |