VOOZH about

URL: https://regexone.com/

⇱ RegexOne - Learn Regular Expressions - Lesson 1: An Introduction, and the ABCs


👁 RegexOne icon
RegexOne
Learn Regular Expressions with simple, interactive exercises.
👁 Interactive Tutorial
Interactive Tutorial 👁 References & More
References & More
All Lessons
Lesson 1: An Introduction, and the ABCs Lesson 1½: The 123s Lesson 2: The Dot Lesson 3: Matching specific characters Lesson 4: Excluding specific characters Lesson 5: Character ranges Lesson 6: Catching some zzz's Lesson 7: Mr. Kleene, Mr. Kleene Lesson 8: Characters optional Lesson 9: All this whitespace Lesson 10: Starting and ending Lesson 11: Match groups Lesson 12: Nested groups Lesson 13: More group work Lesson 14: It's all conditional Lesson 15: Other special characters Lesson X: Infinity and beyond!
Practice Problems
Problem 1: Matching a decimal numbers Problem 2: Matching phone numbers Problem 3: Matching emails Problem 4: Matching HTML Problem 5: Matching specific filenames Problem 6: Trimming whitespace from start and end of line Problem 7: Extracting information from a log file Problem 8: Parsing and extracting data from a URL Problem X: Infinity and beyond!
Language Guides
C# Javascript Java PHP Python
Lesson 1: An Introduction, and the ABCs

Regular expressions are extremely useful in extracting information from text such as code, log files, spreadsheets, or even documents. And while there is a lot of theory behind formal languages, the following lessons and examples will explore the more practical uses of regular expressions so that you can use them as quickly as possible.

The first thing to recognize when using regular expressions is that everything is essentially a character, and we are writing patterns to match a specific sequence of characters (also known as a string). Most patterns use normal ASCII, which includes letters, digits, punctuation and other symbols on your keyboard like %#$@!, but unicode characters can also be used to match any type of international text.

Below are a couple lines of text, notice how the text changes to highlight the matching characters on each line as you type in the input field below. To continue to the next lesson, you will need to use the new syntax and concept introduced in each lesson to write a pattern that matches all the lines provided.

Go ahead and try writing a pattern that matches all three rows, it may be as simple as the common letters on each line.

Exercise 1: Matching characters
Task Text
match abcdefg 👁 To be completed
match abcde 👁 To be completed
match abc 👁 To be completed
Solution

Try typing the first three characters abc to see them match all the lines.

Solve the above task to continue on to the next problem, or read the Solution.
Find RegexOne useful? Please consider
Donating ($4) via Paypal to support our site.
Lesson Notes
abc… Letters
123… Digits
\d Any Digit
\D Any Non-digit character
. Any Character
\. Period
[abc] Only a, b, or c
[^abc] Not a, b, nor c
[a-z] Characters a to z
[0-9] Numbers 0 to 9
\w Any Alphanumeric character
\W Any Non-alphanumeric character
{m} m Repetitions
{m,n} m to n Repetitions
* Zero or more repetitions
+ One or more repetitions
? Optional character
\s Any Whitespace
\S Any Non-whitespace character
^…$ Starts and ends
(…) Capture Group
(a(bc)) Capture Sub-group
(.*) Capture all
(abc|def) Matches abc or def
2025 © RegexOne
Email | Twitter
Additional Courses
Interactive SQL Lessons