Next: astChrSub - Performs substitutions on a supplied string
Up: AST Memory Management and Utility Functions
Previous: astChrSplitC - Split a string using a specified character delimiter
astChrSplitRE
-
Extract sub-strings matching a specified regular expression
- Description:
- 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.
- Synopsis:
- char

astChrSplitRE( const char
str, const char
regexp, int
n,
const char 
matchend )
- Parameters:
-
str
-
Pointer to the string to be split.
-
regexp
-
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.
-
n
-
Address of an int in which to return the number of sub-strings
returned.
-
matchend
-
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:
-
astChrSplitRE()
-
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.
- Notes:
- If a parenthesised sub-string in the regular expression is matched
by more than one sub-string within the test string, then only the
first is returned. To return multiple matches, the regular
expression should include multiple copies of the parenthesised
sub-string (for instance, separated by ".
?" if the intervening
string is immaterial).
- A NULL pointer is returned if this function is invoked with the
global error status set or if it should fail for any reason, or if
the supplied string contains no words.
Next: astChrSub - Performs substitutions on a supplied string
Up: AST Memory Management and Utility Functions
Previous: astChrSplitC - Split a string using a specified character delimiter
AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
24th May 2011
E-mail:ussc@star.rl.ac.uk
Copyright (C) 2009 Science \& Technology Facilities Council