The code creates a Regex object, passing it the regular expression that you want to use for matching. It then invokes the object's Matches method to get a collection of Match objects that represent the places in the test string that match the regular expression.
The code then copies the test string into the result RichTextBox and loops through the collection of matches. For each match, the program selects the matched part of the test string in the RichTextBox and makes ir red.
When the form starts, its regular expression is "in|or|and" so it matches occurrences of "in," "or", and "and."
Comments