Table of Contents

discrete Keyword 3

combination

Definition

A combination is a set containing a certain number of objects that have been selected from another set. In combinations, the order of the elements does not matter.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

discrete Keyword 3 Phase 2

regular expression

Definition

Regular expressions are commands that match a pattern or characters in a string of characters or words. Some of the regular expression commands are the ^ that matches the beginning of a line, the $ matches the end of line, the \< matches the beginning of the line, \> matches the end of the word, . matches any single character, * 0 is 0 or more of the previous character or whatever you put in front of the *, [] matches any of the characters enclosed, [^ ] does not match any of the characters enclosed. Then there is also extended regular characters or egrep. Those are () which is like \( \), | which means or and + which matches 1 or more of the previous character. Usually you have to use a combinations of these to get what you want.

References

Demonstration

Demonstration of regular expression.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

#include <stdio.h>
#include <regex.h>
int main(void)
{
        regex_t reg;
        const char *regex="[abc]";
        const char *str="sadf";
        regmatch_t matches[16];
 
        regcomp(&reg, regex, REG_EXTENDED);
 
        if(regexec(&reg, str, 16, matches, 0) == 0)
        {
                printf("regex /%s/ matched string '%s' at bytes %d-%d\n",
                        regex, str, matches[0].rm_so, matches[0].rm_eo);
        }
        else
                printf("regex /%s/ does not match string '%s'\n", regex, str);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ nano test.c
lab46:~$ gcc -otest test.c
lab46:~$ ./test
regex /[abc]/ matched string 'sadf' at bytes 1-2
lab46:~$