st-re

st-re — functions for matching regular expressions.

Synopsis




#define     st_re_match                     (regexp, str)
gboolean    st_re_parse                     (const regex_t *regexp,
                                             const char *str,
                                             ...);

Description

Details

st_re_match()

#define     st_re_match(regexp, str)

Evaluates to TRUE if str matches regexp.

regexp : a regex_t to match.
str : a string to match regexp against.

st_re_parse ()

gboolean    st_re_parse                     (const regex_t *regexp,
                                             const char *str,
                                             ...);

Checks if str matches regexp, and if it does, distributes the substrings of str matched by the parenthesized subexpressions of regexp.

int status;
regex_t re;
gboolean matches;
char *value1, *value2;
 
status = regcomp(&re, "name1=(.*) name2=(.*)", REG_EXTENDED);
g_assert(status == 0);
 
matches = st_re_parse(&re, "name1=foo name2=bar", &value1, &value2);

regexp : a regular expression to match.
str : a string to match regexp against.
... : a list of char ** pointers for storing substrings of str. The number of char ** pointers provided must be equal to regexp->re_nsub. The strings stored in the pointers should be freed when no longer needed.
Returns : TRUE if str matches regexp.