26 #include <sys/types.h>
46 set(pattern, ignoreCase);
54 set(pattern.c_str(), ignoreCase);
73 if (pattern && *pattern)
77 int cflags = REG_EXTENDED;
83 if (regcomp(preg_, pattern, cflags) != 0)
87 "regExp::set(const char*)"
88 ) <<
"Failed to compile regular expression '" << pattern <<
"'"
97 return set(pattern.c_str(), ignoreCase);
118 if (preg_ && str.size())
121 regmatch_t pmatch[1];
123 if (regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0)
125 return pmatch[0].rm_so;
135 if (preg_ && str.size())
138 regmatch_t pmatch[1];
144 regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
145 && (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
158 if (preg_ && str.size())
160 size_t nmatch = ngroups() + 1;
161 regmatch_t pmatch[nmatch];
168 regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
169 && (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
175 for (
size_t matchI = 1; matchI < nmatch; matchI++)
177 if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1)
179 groups[groupI] = str.substr
181 pmatch[matchI].rm_so,
182 pmatch[matchI].rm_eo - pmatch[matchI].rm_so
187 groups[groupI].
clear();
203 void Foam::regExp::operator=(
const char* pat)
209 void Foam::regExp::operator=(
const std::string& pat)