int RegExpr_FindPatternInText (const char *regularExpressionText, int caseSensitive, const char *textToSearch, int textLength, int direction, int matchPolicy, int *matched, int *matchPosition, int *matchLength);
This function searches a text buffer for a match to a regular expression.
See the Instrument help for example source code showing how to use this function.
Input | |||||||||||||||||||||||||||||||||||||||||
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
regularExpressionText | const char * | A nul–terminated string containing a regular expression. A regular expression consists of the following tokens:
|
|||||||||||||||||||||||||||||||||||||||
caseSensitive | integer | Specifies whether the matching of characters is to be done on a case–senstive or case–insensitive basis. A non–zero value specifies that characters are to be matched on a case–sensitive basis. For example. "chr" would match only to "chr" and not to "CHR". A zero value specifies that characters are to be matched on a case–insensitive basis. For example. "chr" would match to "chr", "CHR", and "Chr". This parameter does apply to ranges. For example, if this parameter is non–zero, then "[a–z]" in the regular expression string would match to any lowercase letter. If this parameter is zero, then "[a–z]" would match to any letter. |
|||||||||||||||||||||||||||||||||||||||
textToSearch | const char * | The text to match to the regular expression. The regular expression must match from the beginning of the text. If you want to search for a regular expression match anywhere in the text, you must call this function iteratively, each time passing the address of the next character in the text. See the Instrument Help for example source code. The function RegExpr_FindPatternInText performs this for you. |
|||||||||||||||||||||||||||||||||||||||
textLength | integer | The number of bytes in the text you want to be included to the search for a match to the regular expression. If you pass a value less than zero, the text is assumed to be nul–terminated, and the full length is used. |
|||||||||||||||||||||||||||||||||||||||
direction | integer | Specifies whether the text is searched starting at the beginning and working forwards or starting at the end and working backwards. Values:
|
|||||||||||||||||||||||||||||||||||||||
matchPolicy | integer | Specifies whether the maximum or minimum number of characters are matched to the pattern. Examples: If the pattern is "a+" and the text to search is "aaaaab", the match could be of length 1 or 5. If you specify RegExpr_MatchLargestNumChars, the match length will be 5. Otherwise, it will be 1. If the pattern is "a+b" and the text to search is "ababab", the match could be of length 2 or 6. If you specify RegExpr_MatchLargestNumChars, the match length will be 6. Otherwise, it will be 2. Values:
|
|||||||||||||||||||||||||||||||||||||||
Output | |||||||||||||||||||||||||||||||||||||||||
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
matched | integer * | If there was a match, this parameter is set to 1. Otherwise, it is set to 0. | |||||||||||||||||||||||||||||||||||||||
matchPosition | integer * | The zero–based index of the position within the text where the match to the regular expression begins. If there was no match, then the parameter is set to |
|||||||||||||||||||||||||||||||||||||||
matchLength | integer * | This parameter is set to the number of characters in the text that actually matched to the regular expression. If there was no match, then the parameter is set to |
Name | Type | Description | ||||||||||||||||||||||||||||||
parseStatus | integer | Indicates if the regular expression was parsed successfully. If the string is not a valid regular expression, a negative error number is returned. You can pass this error number to the RegExpr_GetErrorString function. However, in some cases there is more error information than can be encoded in the error number. You can get more detailed information about the result of the last call to this function by calling RegExpr_GetErrorElaboration. The error numbers are:
|