Learn Regular Expressions in 10 minutes

Опубликовано: 01 Август 2026
на канале: Ivan and Code (Ivan Karaman)
354
16

Regular expressions are "pattern definitions" allowing you to search text. Often they are shortened as "regex" or "regexp". The most common use cases are "text search" and "data validation".
Beware of using them for every situation, regexp are complex and require lots of testing and fine-tuning, unless you are trying to match something very trivial.

A reminder that regexp implementations are slightly different for different programming languages, this tutorial uses Javascript (ECMAScript JS) flavour. Python, C#, SQL, or Java implementations might behave slightly different, always test your regexp before using it in prod!

Check out also the "CSS selectors in 10 minutes" video:
   • Learn CSS selectors in 10 minutes  
And "XPath selectors in 10 minutes":
   • Learn XPath selectors in 10 minutes  
Full playlist:
   • Learn X in Y minutes  

-----------------------------------------------------------------------------------------------
---------- Regular expressions used ----------------------------------------
-----------------------------------------------------------------------------------------------
Frodo - literal match
Frodo|Bilbo - boolean or
(Frodo) - capturing group
. - wildcard (any symbol)

/g - global modifier (don't stop search after a match)
/i - case insensitive modifier
/m - multi-line modifier (each line is an input)

^ - beginning of a string
$ - end of a string

[abcde] - character set (character class)
[^xyz] - negation, "not x, y, or z"
[A-Fa-z1-5] - character set range

? - zero or one (optional) quantifier
- one or more quantifier
- zero or more quantifier
{1} - exactly X quantifier
{1,} - one or more quantifier
{3,5} - range quantifier "from 3 to 5"

-----------------------------------------------------------------------------------------------
---------- Bonus link ----------------------------------------------------------------
-----------------------------------------------------------------------------------------------
Look at this list of "valid email examples" and re-evaluate your choice of using regexp for validation of email (or anything else with some degree of complexity)
https://en.wikipedia.org/wiki/Email_a...

-----------------------------------------------------------------------------------------------
---------- Timeline -------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
0:00 - intro
0:36 - different regexp flavours
1:23 - literal character
1:46 - metacharacter
2:13 - boolean "or"
2:35 - capturing groups
2:57 - global modifier
3:42 - case insensitive modifier
4:06 - start/end of a string
4:38 - multi-line modifier
5:03 - character sets
5:45 - character set negation
6:03 - character set range
6:40 - ? quantifier
7:50 - + and * quantifiers
8:38 - {} range quantifiers
9:11 - warning