gchar* string_regex_formatted_combine | ( | const gchar * | str, | |
const gchar * | pattern, | |||
const gchar * | format, | |||
int | cflags, | |||
int | eflags, | |||
int * | counter_ptr | |||
) |
This function combines sub-matches of a regex search into a specified format.
It also generates regex_t
and frees it before the returning. Consider use regcomp() and string_regex_formatted_combine_regex_t() if same pattern
will be use many times.
Use free() or g_free() to free the result.
str | String to be matched. | |
pattern | Pattern for matching. | |
format | the format of output string, which consists one to multiple pattern substitute. | |
cflags | Flags for regcomp(). | |
eflags | Flags for regexec(). | |
counter_ptr | a pointer to an integer counter. Can be NULL if + or - flags are not required. |
gchar* string_regex_formatted_combine_regex_t | ( | const gchar * | str, | |
const regex_t * | preg, | |||
const gchar * | format, | |||
int | eflags, | |||
int * | counter_ptr | |||
) |
This function combines sub-matches of a regex search into a specified format. Use this function if the regex expression is already complied as a regex_t
.
Use free() or g_free() to free the result, also regfree() preg
if no longer used.
str | String to be matched. | |
preg | regex pattern buffer which is generated by regcomp(). | |
format | the format of output string, which consists one to multiple pattern substitute. | |
eflags | Flags for regexec(). | |
counter_ptr | a pointer to an integer counter. Can be NULL if + or - flags are not required. |
gchar* string_regex_replace | ( | const gchar * | str, | |
const gchar * | pattern, | |||
const gchar * | format, | |||
int | cflags, | |||
int | eflags, | |||
int * | counter_ptr | |||
) |
This function replaces the regex matched sub-string to the string specified in format
, and returns a newly allocated string that holds the result.
This function differs with string_regex_eval_regex_t(), as string_regex_formatted_combine_regex_t() substitutes and returns only the matched substring, while this function keeps the parts that does not match the pattern.
Use free() or g_free() to free the result.
str | String to be matched. | |
pattern | Pattern for matching. | |
format | the format of output string, which consists one to multiple pattern substitute. | |
cflags | Flags for regcomp(). | |
eflags | Flags for regexec(). | |
counter_ptr | a pointer to an integer counter. Can be NULL if + or - flags are not required. |
gchar* string_regex_replace_regex_t | ( | const gchar * | str, | |
const regex_t * | preg, | |||
const gchar * | format, | |||
int | eflags, | |||
int * | counter_ptr | |||
) |
This function replaces the regex matched sub-string to the string specified in format
, and returns a newly allocated string that holds the result.
This function differs with string_regex_formatted_combine_regex_t(), as string_regex_formatted_combine_regex_t() substitutes and returns only the matched substring, while this function keeps the parts that does not match the pattern.
Use free() or g_free() to free the result.
str | String to be matched. | |
preg | regex pattern buffer which is generated by regcomp(). | |
format | the format of output string, which consists one to multiple pattern substitute. | |
eflags | Flags for regexec(). | |
counter_ptr | a pointer to an integer counter. Can be NULL if + or - flags are not required. |