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

Method match

plugins/prefetch/pattern.cc:204–223  ·  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

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

Callers 1

TSRemapDoRemapFunction · 0.45

Calls 3

pcre_execFunction · 0.85
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected