Chapter 5. Regular Expressions
When you are scripting, you will run into situations where you need to validate strings to see if they meet certain criteria. While you have the ability to use comparison operators to view if a string matches a certain value, you don't have the ability to validate parts of a string. A good example is of IP addresses. The comparison operators don't have the ability to validate the syntax of an IP address. If you were to use the normal comparison operators to validate an IP address syntax, you would have to build a script that would split the numerical values, verify that it has 4 octets, validate the individual numerical values, and pass a True
or False
value. Regular expressions solve this problem by providing deep comparison operations in a single string to verify that strings meet certain criteria.
In this chapter, you will learn about:
- Common metacharacters
- Grouping constructs and ranges
- Regular expression quantifiers
- Regular expression anchors...