Регулярные выражения за 5 минут
Литералы, классы и квантификаторы
«Регулярные выражения за 5 минут» — бесплатный урок NLP Academy на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения NLP Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс NLP Academy содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
A Tiny Language for Patterns
A regular expression is a tiny pattern language for matching text. Instead of one fixed word, you describe the shape of what you want to find.
Python Speaks Regex Too
Python uses the built-in re module for regex. Import it once and you can search, match, and extract patterns from any string.
import re
re.search("cat", "the cat sat")Literals: Exact Characters
The simplest pattern is a literal. The pattern dog matches the exact letters d, o, g, in that order, wherever they appear in your text.
search Finds the First Match
Use re.search to scan a string and return the first place your pattern appears, or None when nothing matches at all.
m = re.search("sat", "the cat sat")
print(m.group())Character Classes With Brackets
A character class in square brackets matches any one listed character. The pattern [abc] matches a single a, b, or c each time.
re.findall("[aeiou]", "hello")Handy Class Shortcuts
Some classes have shortcuts. \d matches any digit, \w matches word characters, and \s matches spaces. They save you a lot of typing. 😊
The Dot Matches Anything
The dot stands for any single character except a newline. So h.t matches hat, hit, and hot, but never the two-letter ht.
Quantifiers Repeat Patterns
A quantifier says how many times the part before it repeats. Add a plus for one or more, a star for zero or more.
re.findall("a+", "aaa banana")Exact Counts With Braces
Use braces for precise repetition. The pattern \d{3} matches exactly three digits in a row, perfect for area codes or short IDs.
re.findall("\d{3}", "call 911 now")Anchors Pin the Position
Anchors match a position, not a character. The caret means start of string and the dollar sign means end of string.
findall Returns Every Match
While search finds one match, re.findall returns a list of every match in the text, which is great for counting or extracting many items.
re.findall("\d+", "2 cats, 5 dogs")Quick Check
You want to match exactly three digits in a row. Which pattern fits?
Recap: Your Regex Toolkit
You met literals, classes, the dot, quantifiers, and anchors. With re.search and re.findall, you can already describe and find real patterns. 🎉
Часто задаваемые вопросы
Урок «Регулярные выражения за 5 минут» бесплатный?
Да — полный текст урока «Регулярные выражения за 5 минут» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс NLP Academy, подпишись на CoddyKit PRO. Курс NLP Academy содержит 4 уроков всего.
Чему я научусь в уроке «Регулярные выражения за 5 минут»?
Литералы, классы и квантификаторы Ты практикуешь NLP Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать NLP Academy?
Предыдущий опыт не требуется. NLP Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.
Сколько времени занимает урок «Регулярные выражения за 5 минут»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке NLP Academy?
Да. Каждый урок NLP Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Регулярные выражения за 5 минут
- Поиск адресов электронной почты и URL
- Группы захвата и замены
- Приёмы токенизации с регулярными выражениями