You can use regular expressions to determine if a character string of interest is matched somewhere in a set of character strings. You can specify more than one character string to search for.
To use a regular expression in your code, first compile the expression with regcomp. You can then use regexec to search for a matching sequence using the compiled expression. If an error occurs, regerror provides information about the error. When you have finished with the expression, use regfree to free it from memory.
To support Extended Regular Expressions, specify the REG_EXTENDED flag for the regcomp function.
The search for a matching sequence starts at the beginning of the string and stops when the first sequence matching the expression is found. The first sequence is the one that begins earliest in the string. If the pattern permits matching several sequences at this starting point, the longest sequence is matched.