Extract sub-strings matching a specified regular expression


This function compares the supplied string with the supplied regular expression. If they match, each section of the test string that corresponds to a parenthesised sub-string in the regular expression is copied and stored in the returned array.


char astChrSplitRE( const char str, const char regexp, int n, const char matchend )


Pointer to the string to be split.
The regular expression. See " Template Syntax:" in the astChrSub prologue. Note, this function differs from astChrSub in that any equals signs (=) in the regular expression are treated literally.
Address of an int in which to return the number of sub-strings returned.
A pointer to a location at which to return a pointer to the character that follows the last character within the supplied test string that matched any parenthesises sub-section of " regexp" . A NULL pointer is returned if no matches were found. A NULL pointer may be supplied if the location of the last matching character is not needed.

Returned Value

A pointer to a dynamically allocated array containing " n" elements. Each element is a pointer to a dynamically allocated character string containing a sub-string extracted from the supplied string. The array itself, and the strings within it, should all be freed using astFree when no longer needed.