Utility Functions and C Language Reference > Utility Functions: C Language (lr_) > Alphabetical Listing > lr_save_param_regexp


Finds a match or matches to a regular expression in a buffer, and saves the capture group to a parameter.

C Language

int lr_save_param_regexp (char* bufferToSearch, int bufferSize, char * RegExp[/IC], int Ordinal, char * ResultParam);
Example of Parameter Array Use String and Parameter Functions


Name Comments
bufferToSearch The buffer in which to search for matches. The buffer can contain binary data.
bufferSize In bytes.
RegExp[/IC] A regular expression with exactly one capture group. If IC is appended to the name of the argument, the search is not case sensitive. For example, "RegExp/IC=(r*)" matches 'RR' and 'rRr'.

The 1-based location of the match to find. For example, "Ordinal=2" finds the second match.

A value of 0 indicates to find all matches and save the capture strings in a parameter array. The symbol All can be used in place of 0. For example, "Ordinal=All".

ResultParam The name of the parameter or parameter array to save the matches in.

lr_save_param_regexp searches inside a buffer for a match or matches to a regular expression.

If Ordinal is an integer greater than 0 and at least that number of matches is found, a parameter is created with the name specified by the ResultParam argument. The value of the parameter is the capture group of the match.

If Ordinal is ALL (0) and at least one match is found, a parameter array is created. The values of the parameters are the capture groups of the matches.

The parameter is not created if either no matches are found or if an Ordinal value is specified and fewer matches are found. For example, if "Ordinal=3" and only 2 matches are found, the parameter is not created.

If there are multiple calls with the same result parameter, each call overwrites the previous value.

The last result parameter value from a call to lr_save_param_regexp in an iteration persists between iterations. The first call in an iteration overwrites the previous value.

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure. Note that in many cases, this return value indicates the technical success of the function, and not the result. For example, a function that registers a string to be found in a subsequent step returns LR_PASS to indicate that the registration was successful. This does not indicate that the string was found in the server response.


Standard parameterization is not available for this function.

Concept Link IconSee Also