This chapter introduces the library for regular expressions. That library allows you to use wildcards and patterns to search and replace characters in strings.
In principle, you can do the following with regular expressions:
• Match the whole input against a regular expression
• Search for patterns that match a regular expression
• Tokenize a character according to a token separator specified as a regular expression
• Replace in the first or all subsequences that match a regular expression
For all these operations, you can use different grammars, which are used to define a regular expres- sion.
I begin this chapter by introducing the various operations, then discussing different grammars, and finally listing the regex operations in detail.
14.1 The Regex Match and Search Interface
First, let’s look at how we can check whether a sequence of characters matches or partially matches a specific regular expression: