Visible to Intel only — GUID: GUID-D01D3660-186D-4D29-AADA-A50D173A5F56
Visible to Intel only — GUID: GUID-D01D3660-186D-4D29-AADA-A50D173A5F56
RegExpFind
DEPRECATED. Looks for the occurrences of the substrings matching the specified regular expression.
Syntax
IppStatus ippsRegExpFind_8u(const Ipp8u* pSrc, int srcLen, IppRegExpState* pRegExpState, IppRegExpFind* pFind, int* pNumFind);
Include Files
ippch.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
Parameters
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. |
Description
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 ippsRegExpInit function 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.
If number of matches exceeds the size of the pFind array, the function returns ippStsOverflow status. In this case you should increase pNumFind value and repeat the search.
It is recommended to set the default value of the parameter matchLimit in accordance with real necessity by calling the function ippsRegExpSetMatchLimit beforehand.
Return Values
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. |
ippStsOverflow |
The size of pFind array is less than the number of matching substrings. |
Example
/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/
// The code example below shows how to use regular expression functions:
// ippsRegExpGetSize
// ippsRegExpInit
// ippsRegExpFind_8u
#include <stdio.h>
#include "ipp.h"
/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine: /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Primitives (Intel(R) IPP) function returned status different from ippStsNoErr */
/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */
static Ipp8u string[] = "Hello World!";
int main(void)
{
const char pattern[] = "[ hH ]ello (\\w+)";
IppRegExpFind find[2] = {0};
int find_num = sizeof (find)/ sizeof (find[0]);
IppStatus status = ippStsNoErr;
int i = 0, errOffset = 0;
IppRegExpState *pRegExpState = NULL;
int regExpStateSize = 0;
check_sts( status = ippsRegExpGetSize( pattern, ®ExpStateSize ) )
pRegExpState = (IppRegExpState*)ippMalloc( regExpStateSize );
check_sts( status = ippsRegExpInit( pattern, NULL, pRegExpState, &errOffset ) )
check_sts( status = ippsRegExpFind_8u( string, sizeof (string) - 1, pRegExpState, 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;
}
EXIT_MAIN
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}