Looks for the occurrences of the substrings matching the specified regular expression.
IppStatus ippsRegExpFind_8u(const Ipp8u* pSrc, int srcLen, IppRegExpState* pRegExpState, IppRegExpFind* pFind, int* pNumFind);
pSrc |
Pointer to the source strings. |
srcLen |
Number of elements in the source string. |
pRegExpState |
Pointer to the structure containing internal form of regular expression. |
pFind |
Array of pointers to the matching substrings. |
pNumFind |
Size of the array pFind on input, number of matching substrings on output. |
The function ippsRegExpFind is declared in the ippch.h file. This function search through the srcLen elements of the source string pSrc for substrings that match the specified regular expression in accordance with the regular expression pattern that is stored in the structure pRegExpState. This structure must be initialized by the functions ippsRegExpInit or ippsRegExpInitAlloc beforehand. Initially the parameter pNumFind specifies the size of array pFind, the output parameter pNumFind returns the number of the matching substrings.
pFind->pFind specifies the offset of the pointer to the matching substring, and pFind->lenFind - number of elements in the matching substring. pFind [0] points to the substring that matches the whole regular expression, pFind [1] points to the substring that matches the first grouping, pFind[2] points to the substring that matches the second grouping, and so on.
It is recommended to set the default value of the parameter matchLimit in accordance with real necessity by calling the function ippsRegExpSetMatchLimit beforehand.
Code example below shows how to use the function ippsRegExpFind_8u.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error condition if one of the specified pointers is NULL. |
ippStsSizeErr |
Indicates an error condition if srcLen is negative, or pNumFind is less than or equal to 0. |
ippStsRegExpErr |
The state structure pRegExpState contains wrong data. |
ippStsRegExpMatchLimitErr |
The match limit has been exhausted. |
Ipp8u string[] = "Hello World!";
IppRegExpFind find[2];
int find_num = sizeof (find)/ sizeof (find[0]);
IppRegExpState *state;
IppStatus status;
int i , err;
ippsRegExpInitAlloc ("[ hH ] ello (\\w+)", NULL, &state, &err );
ippsRegExpFind_8u( string, sizeof (string) - 1, state, find, & find_num );
printf ( "Found strings number = %d\n", find_num );
for( i = 0; i < find_num ; i ++ ) {
Ipp8u tmp = ((Ipp8u*)find[ i ]. pFind )[find[ i ]. lenFind ];
((Ipp8u*)find[ i ]. pFind )[find[ i ]. lenFind ] = 0;
printf ( "%d: %s\n", i, (char*)find[ i ]. pFind );
((Ipp8u*)find[ i ]. pFind )[find[ i ]. lenFind ] = tmp ;
}
Output:
Found strings number = 2
0: Hello World
1: World
Copyright © 2000 - 2010, Intel Corporation. All rights reserved.