BloombergLP::bdlpcre::RegEx::match

Match subject against pattern(), loading the match offset and length into result.

Synopsis

Declared in <bdlpcre_regex.h>

int
match(
    bsl::pair<size_t, size_t>* result,
    char const* subject,
    size_t subjectLength,
    size_t subjectOffset = 0) const;

Description

Match the specified subject having the specified subjectLength against pattern(). Begin matching at the optionally specified subjectOffset in subject. If subjectOffset is not specified, matching begins at the start of subject. subject may contain embedded null characters. UTF-8 validity checking is performed on subject if pattern() was prepared with k_FLAG_UTF8. Return k_STATUS_SUCCESS on success, k_STATUS_NO_MATCH if a match is not found, and another value if an error occurs. If the returned status is not k_STATUS_SUCCESS or k_STATUS_NO_MATCH it may match one of specific k_STATUS_* error return constants defined above (but is not guaranteed to). result is unchanged if a value other than k_STATUS_SUCCESS is returned. The behavior is undefined unless true == isPrepared(), subject || 0 == subjectLength, and subjectOffset <= subjectLength. Note that JIT optimization is disabled if pattern() was prepared with k_FLAG_UTF8; use matchRaw if JIT is preferred and UTF-8 validation of subject is not required.

Return Value

k_STATUS_SUCCESS on success, k_STATUS_NO_MATCH if no match, or another status on error

Parameters

NameDescription
resultreceives the (offset, length) of the match
subjectsubject string to match (need not be null-terminated)
subjectLengthlength of subject in bytes
subjectOffsetoffset in subject at which matching begins