Schedule pattern matching for the given UTF-8 text.


#include </strpattern.h>
long strpattern_analyzeUTF8(const char *text, strpattern_analyze_callback_func callback, void *user_data, const strpattern_context *context, int *err)



Text to be analyzed for pattern matches which is UTF-8 encoded and NULL-terminated. Ownership is retained by the caller.


The callback called to deliver the result of pattern matching (cannot be NULL).


User-defined data passed to the callback (can be NULL). Memory is managed by the client of this library.


The context used for the pattern matching (can be NULL). Ownership is retained by the caller.


STRPATTERN_EOK if there is no error.




This function is identical to strpattern_analyze() except that it operates on UTF-8 encoded text.

This function analyzes the given string using data specified by the user and returns the results using the given callback function. The callback is called even if there are errors. The callback is not called if the pattern matching is canceled because of a call to strpattern_cancel() before the actual matching process has finished. Pattern matching may or may not run in the calling function's thread. For strings with short length (native length less than 10), pattern matching is normally run in the calling function's thread.

The text must not be modified in another thread such as during the execution of this function.

Note: The callback may be run in a separate thread. Make sure that any data access and function calls from inside the callback are done in a thread-safe way by using locks when appropriate.

Each method call returns a unique ID. This ID can be used to cancel the corresponding pattern matching using a call to strpattern_cancel().

Sample code:

 char s[] = "sample text";
 int err;
 strpattern_analyzeUTF8(s, &your_callback, NULL, NULL, &err);


A unique ID assigned to this pattern matching call.