MCPcopy Create free account
hub / github.com/apache/trafficserver / match

Method match

plugins/cachekey/pattern.cc:205–224  ·  view source on GitHub ↗

* @brief PCRE matches a subject string against the regex pattern. * @param subject PCRE subject * @return true - matched, false - did not. */

Source from the content-addressed store, hash-verified

203 * @return true - matched, false - did not.
204 */
205bool
206Pattern::match(const String &subject)
207{
208 int matchCount;
209 CacheKeyDebug("matching '%s' to '%s'", _pattern.c_str(), subject.c_str());
210
211 if (!_re) {
212 return false;
213 }
214
215 matchCount = pcre_exec(_re, _extra, subject.c_str(), subject.length(), 0, PCRE_NOTEMPTY, nullptr, 0);
216 if (matchCount < 0) {
217 if (matchCount != PCRE_ERROR_NOMATCH) {
218 CacheKeyError("matching error %d", matchCount);
219 }
220 return false;
221 }
222
223 return true;
224}
225
226/**
227 * @brief Return all PCRE capture groups that matched in the subject string

Callers 3

toBeAddedMethod · 0.45
classifyMethod · 0.45
mainFunction · 0.45

Calls 3

pcre_execFunction · 0.85
c_strMethod · 0.45
lengthMethod · 0.45

Tested by 1

mainFunction · 0.36