JavaScript for Beginners
Variables, functions, arrays, objects, the DOM and async code
Technology & ProgrammingMatch, extract and replace text with regex in JavaScript, Python and your editor
Finish the 12 lessons (about 2 h 45 min) and pass the 20-question final exam. Your Certificate of Completion is ready the moment you pass.
Regular expressions turn hours of manual text work into one line: find every date in a log file, pull email addresses out of a document, reformat thousands of phone numbers, or check that a form field holds a valid ZIP code. They work in nearly every programming language, in command-line tools like grep and sed, and in the find-and-replace box of your code editor. This free course takes you from your first literal match to patterns that experienced developers trust in production.
You'll start with the fundamentals: literal characters, metacharacters and escaping, character classes and ranges, shorthand classes such as digits and word characters, and quantifiers, including the difference between greedy and lazy matching. Then you'll learn structure: anchors and word boundaries for validation, alternation and its precedence trap, capturing and non-capturing groups, backreferences, named groups and search-and-replace with captured text.
Next you'll use regex in real code. You'll write JavaScript with test, match, matchAll, replace and split, avoid the lastIndex and double-escaping traps, and use Python's re module with raw strings, search, fullmatch, findall and sub. The advanced module covers lookahead and lookbehind, how backtracking engines work and how to avoid catastrophic backtracking. The final module builds practical patterns for emails, phone numbers, dates and IP addresses, shows when a parser is the better tool, and teaches readable, tested, Unicode-aware regex.
The course is for students and developers who know the basics of at least one programming language. Every lesson includes coding exercises that run in your browser, plus quick checks and scenarios, and passing the final exam earns you a free certificate of completion.
What regular expressions are, how literal characters and character classes match text, and how quantifiers control repetition.
Pin patterns to positions with anchors and word boundaries, combine options with alternation, and capture parts of a match for extraction and replacement.
Use regular expressions from JavaScript and Python, avoid the classic escaping and global-flag pitfalls, and apply regex in command-line tools and editors.
Check context without consuming it using lookarounds, understand how the engine backtracks, and avoid patterns that become catastrophically slow.
Build practical patterns for emails, phone numbers, dates and IP addresses, know when a parser beats a regex, and keep patterns readable, tested and Unicode-aware.
20 questions drawn from a pool of 34. Score 70% or more to pass; retakes get a fresh set of questions.
Which task is a good fit for a regular expression?
Answer: B. Finding every US phone number written as 555-123-4567 in a document
Regex describes the shape of text, and phone numbers in a fixed format have a clear shape: digits and dashes in a set pattern. Averages and sorting are computation, and translation needs language understanding, which a pattern cannot provide.
The core is shared almost everywhere: literals, character classes, quantifiers, anchors, groups and alternation work the same in JavaScript, Python, Java, C#, PHP and most tools. Advanced features such as lookbehind, named group syntax, Unicode properties and replacement syntax differ between flavors, so check the documentation when moving a pattern between languages.
A greedy quantifier such as .* matches as much text as possible and gives characters back only if the rest of the pattern needs them. A lazy quantifier such as .? matches as little as possible. For matching up to a delimiter, a negated class like [^"] is often clearer and faster than either.
Use a simple, permissive pattern to catch obvious typos, such as one @ with text on both sides and a dot in the domain. Overly strict patterns reject real addresses, and no pattern can confirm that a mailbox exists. Sending a confirmation email is the only real check.
Not reliably. These formats nest structures inside each other to any depth, which classic regular expressions cannot track. Use an HTML parser or a JSON parser instead. Regex is still handy for quick searches inside such files.
Most likely catastrophic backtracking. Patterns with nested quantifiers, like (a+)+, or overlapping alternatives can force a backtracking engine to try an exponential number of combinations when a match fails. Rewrite the pattern so each character can be matched only one way, limit input length, or use a linear-time engine.
Online regex testers highlight matches as you type, explain each part of a pattern and let you pick the flavor. Code editors support regex in find and replace, and command-line tools like grep and ripgrep let you test patterns on real files. Keep your test strings as automated tests once the pattern works.
No. It is a certificate of completion showing that you finished the lessons and passed the final exam. It is useful for documenting your learning, but it is not an academic or professional credential.
Variables, functions, arrays, objects, the DOM and async code
Technology & ProgrammingWrite real programs with variables, loops, lists, dictionaries and functions
Technology & ProgrammingWrite real programs: games, quizzes and calculators from your first line of code
Technology & ProgrammingCode real browser games with variables, loops, canvas drawing, keys and collisions
Technology & ProgrammingTrack changes, branch safely and collaborate with pull requests
Technology & ProgrammingAlgorithms, loops, if-then, variables and bug hunting, then write real JavaScript
Technology & Programming