next up previous contents index
Next: String List Handles Up: Main Functions 2 Previous: Path Manipulation and Query   Contents   Index

Regular Expressions

(regex_handle) RegCompile(regex, case_insens)
This function returns a handle to a compiled regular expression, as given in the first (string) argument. The handle can be used for string comparison in RegCompare, and should be closed when no longer needed. The second argument is a flag; if nonzero the regular expression is compiled such that comparisons will be case-insensitive. If zero, the test will be case-sensitive. If the compilation fails, this function returns 0, and an error message can be obtained from RegError.

(int) RegCompare(regex_handle, string, array)
This function compares the regular expression represented by the handle to the string given in the second argument. If a match is found, the function returns 1, and the match location is set in the array argument, unless 0 is passed for this argument. If an array is passed, it must have size 2 or larger. The 0'th array element is set to the character index in the string where the match starts, and the next array location is set to the character index of the first character following the match. This function returns 0 if there is no match, and -1 if an error occurs. If -1 is returned, an error message can be obtained from RegError.

(string) RegError(regex_handle)
This function returns an error message string produced by the failure of RegCompile or RegCompare. It can be called after one of these functions returns an error value. The argument is the handle value returned from RegCompile, which will be 0 if RegCompile fails. A null string is returned if the handle is bogus.


next up previous contents index
Next: String List Handles Up: Main Functions 2 Previous: Path Manipulation and Query   Contents   Index
Stephen R. Whiteley 2024-09-29