* @brief PCRE matches a subject string against the regex pattern. * @param subject PCRE subject * @return true - matched, false - did not. */
| 203 | * @return true - matched, false - did not. |
| 204 | */ |
| 205 | bool |
| 206 | Pattern::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 |