Logo Search packages:      
Sourcecode: rapple version File versions  Download package

unsigned rpl_regex_match ( rpl_regex_t *  re_p,
rpl_str_t  str,
int  offset 
)

Returns true if the RE is found in the string.

Parameters:
re_p Pointer to the RE.
str the string to search for the RE.
offset the offset into the string to start the search. If set to -1 then the search starts at the start of the string.

Definition at line 114 of file regex.c.

References rpl_me_free(), and rpl_me_malloc().

Referenced by rpl_regex_replace().

{
    size_t len = strlen (str);

    assert (re_p != NULL);
    assert (re_p->pcre_pm != NULL);
    assert (re_p->ovector_pam != NULL);

    if ((offset > len) || (len == 0)) return 0;

    /* replace the source string but first free the memory used by previous
     * string
     */
    if (re_p->src_str_m != NULL)
        rpl_me_free (re_p->src_str_m);
    re_p->src_str_m = (rpl_str_t) rpl_me_malloc (len);
    strncpy (re_p->src_str_m, str, len);

    if (offset < 0)
    {
        offset = 0;
    }

    re_p->result_m = pcre_exec (re_p->pcre_pm,
                                NULL,
                                str,
                                len,
                                offset,
                                0,
                                re_p->ovector_pam,
                                re_p->ovec_size_m);

    return (re_p->result_m > 0);
}


Generated by  Doxygen 1.6.0   Back to index