Regex w 5 minut
Literały, klasy i kwantyfikatory
Regex w 5 minut to bezpłatna lekcja NLP Academy na CoddyKit. To lekcja 1 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej NLP Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs NLP Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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. 🎉
Często zadawane pytania
Czy lekcja „Regex w 5 minut” jest bezpłatna?
Tak — pełny tekst „Regex w 5 minut” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu NLP Academy, przejdź na CoddyKit PRO. Kurs NLP Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Regex w 5 minut”?
Literały, klasy i kwantyfikatory Ćwiczysz NLP Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć NLP Academy?
Nie wymagamy żadnego doświadczenia. NLP Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 1 z 4.
Ile czasu zajmuje lekcja „Regex w 5 minut”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji NLP Academy?
Tak. Każda lekcja NLP Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Regex w 5 minut
- Wyszukiwanie adresów e-mail i URL-i
- Grupy przechwytujące i zamiany
- Triki tokenizacji za pomocą regexów