Lines Matching refs:regex
171 void RE::Init(const char* regex) { in Init() argument
172 pattern_ = posix::StrDup(regex); in Init()
176 const size_t full_regex_len = strlen(regex) + 10; in Init()
179 snprintf(full_pattern, full_regex_len, "^(%s)$", regex); in Init()
190 const char* const partial_regex = (*regex == '\0') ? "()" : regex; in Init()
194 << "Regular expression \"" << regex in Init()
251 std::string FormatRegexSyntaxError(const char* regex, int index) { in FormatRegexSyntaxError() argument
253 << " in simple regular expression \"" << regex << "\": ").GetString(); in FormatRegexSyntaxError()
258 bool ValidateRegex(const char* regex) { in ValidateRegex() argument
259 if (regex == NULL) { in ValidateRegex()
271 for (int i = 0; regex[i]; i++) { in ValidateRegex()
272 if (regex[i] == '\\') { // An escape sequence in ValidateRegex()
274 if (regex[i] == '\0') { in ValidateRegex()
275 ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) in ValidateRegex()
280 if (!IsValidEscape(regex[i])) { in ValidateRegex()
281 ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) in ValidateRegex()
282 << "invalid escape sequence \"\\" << regex[i] << "\"."; in ValidateRegex()
287 const char ch = regex[i]; in ValidateRegex()
290 ADD_FAILURE() << FormatRegexSyntaxError(regex, i) in ValidateRegex()
293 } else if (ch == '$' && regex[i + 1] != '\0') { in ValidateRegex()
294 ADD_FAILURE() << FormatRegexSyntaxError(regex, i) in ValidateRegex()
298 ADD_FAILURE() << FormatRegexSyntaxError(regex, i) in ValidateRegex()
302 ADD_FAILURE() << FormatRegexSyntaxError(regex, i) in ValidateRegex()
322 bool escaped, char c, char repeat, const char* regex, in MatchRepetitionAndRegexAtHead() argument
332 if (i >= min_count && MatchRegexAtHead(regex, str + i)) { in MatchRepetitionAndRegexAtHead()
348 bool MatchRegexAtHead(const char* regex, const char* str) { in MatchRegexAtHead() argument
349 if (*regex == '\0') // An empty regex matches a prefix of anything. in MatchRegexAtHead()
354 if (*regex == '$') in MatchRegexAtHead()
358 const bool escaped = *regex == '\\'; in MatchRegexAtHead()
360 ++regex; in MatchRegexAtHead()
361 if (IsRepeat(regex[1])) { in MatchRegexAtHead()
366 escaped, regex[0], regex[1], regex + 2, str); in MatchRegexAtHead()
371 return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) && in MatchRegexAtHead()
372 MatchRegexAtHead(regex + 1, str + 1); in MatchRegexAtHead()
384 bool MatchRegexAnywhere(const char* regex, const char* str) { in MatchRegexAnywhere() argument
385 if (regex == NULL || str == NULL) in MatchRegexAnywhere()
388 if (*regex == '^') in MatchRegexAnywhere()
389 return MatchRegexAtHead(regex + 1, str); in MatchRegexAnywhere()
393 if (MatchRegexAtHead(regex, str)) in MatchRegexAnywhere()
418 void RE::Init(const char* regex) { in Init() argument
420 if (regex != NULL) { in Init()
421 pattern_ = posix::StrDup(regex); in Init()
424 is_valid_ = ValidateRegex(regex); in Init()
430 const size_t len = strlen(regex); in Init()
437 if (*regex != '^') in Init()
442 memcpy(buffer, regex, len); in Init()
445 if (len == 0 || regex[len - 1] != '$') in Init()