Quick Recap # In Part 4, we covered quantifiers: * (zero or more), + (one or more), ? (optional), and {n,m} (specific counts). We also learned that quantifiers apply to the element directly before them. Now let’s talk about the characters regex treats as special and how to handle them. The 14 Metacharacters # Regex has 14 characters that have special meaning. These are called metacharacters: . * + ? ^ $ { } [ ] ( ) | \ When the engine sees any of these, it doesn’t treat them as literal characters. It interprets them as instructions. We’ve already used several: ^ and $ as anchors, * + ? as quantifiers, [] for character classes. One note: This lesson isn’t about what these special characters do. A future lesson will cover what meta characters are used for in more detail. Escaping with Backslash # What if you actually want to match a literal dot, or a literal asterisk? You put a backslash \ before it. This is called escaping. The backslash tells the engine “treat the next character as a…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.