Learn regular expressions one tiny step at a time with 10 practical examples. Each one builds on the last, so you can master regex slowly and confidently!
Concept: Literal characters. This matches the exact word "cat". Use it to find a specific word in text.
Concept: Digit character \d. This matches any single digit (0-9). Use it to find numbers in text.
Concept: Quantifier +. This matches one or more digits in a row. Use it to find numbers like years or prices.
Concept: Letter range [a-z]. This matches any lowercase letter. Use it to find letters in text.
Concept: Character set [a-z0-9]. This matches any lowercase letter or digit. Use it to find parts of usernames or codes.
Concept: Alternation |. This matches "yes" or "no". Use it to find specific choices in text.
Concept: Start anchor ^. This checks if a string starts with "Hi". Use it to validate greetings or headers.
Concept: End anchor $. This checks if a string ends with "bye". Use it to validate closings or file extensions.
Concept: Word boundary \b. This matches "cat" as a whole word, not inside "catalog". Use it for exact word searches.
Concept: Combining basics. This matches a code like "A123" (letter then 3 digits). Use it to validate short IDs.
Try changing the text in each example and click "Test" to see how the regex works. Have fun learning!