
Trace the history of regular expressions from 1950s origins to PCRE, and learn how the syntax transfers to JavaScript and other languages for text processing, validation, and extraction.
Learn to use regular expressions in JavaScript with regex object methods (test, exec) and string methods (match, search, replace, split) through examples.
Understand how regular expressions are built from individual characters, how the engine tests matches by moving through the string and rewinding, and how metacharacters, including the wildcard, govern pattern interpretation.
Master the dot wildcard in JavaScript regular expressions: it matches any single character except newline, use the global flag to find multiple matches, and learn to escape a literal period.
In the previous topic I mentioned that the wildcard character . represents any single character with the exception of some control characters like new line. Well in ECMAScript release 2018 a new flag was added to regular expressions in JavaScript. The new flag is the letter 's' and it called the dotAll Flag. This flag can be added to your regular expression if you would like the wildcard character to match all characters.
The dotAll flag can be included with other flags such as global 'g' or case insensitive 'i'.
Escape metacharacters in JavaScript regular expressions using the backslash to treat special characters as literals. See how a period and a backslash become literal values to prevent unintended matches.
Explore the first JavaScript exercise by filtering a phone-number array to include only 801 area codes with a regular expression, using the browser and console logs.
Explore simple regular expressions to match numbers starting with 801- using a hyphen, and compare two implementations: array filter with regex test and a loop, to extract matching phone numbers.
Use square brackets to form character sets that match one of several letters, such as gray with a or e, and apply the global flag for all matches.
Illustrate ranges in a character set using the hyphen as a range, escaping when needed. Show digits, letters, and punctuation matched by single-character sets, and ranges apply to individual characters.
Explore how to exclude characters with negated sets using the caret at the start, including ranges like 0-9 and A-F, and how to escape the caret.
Explore shorthand character sets in JavaScript regular expressions, including digits, word characters, whitespace, their negations, global flag, demonstrated with regex pal examples.
This lecture guides you through exercise 2 of the JavaScript course, extending the previous task by validating a list of phone numbers with a regex and filtering out invalid entries.
Build a phone number regex using digit shorthand for the three and four digit groups separated by a hyphen, and note how missing an end anchor permits extra trailing digits.
Learn how repetition works in JavaScript regular expressions with plus, question mark, and asterisk meta characters after the leftmost item, and explore greediness and 0 or 1 behaviors.
Understand greediness and laziness in regular expressions with paragraph tag examples, wildcards, and backtracking. Learn how the ? makes repetition lazy and how global affects matches.
Explore repetition amounts in regex with curly braces after an item, using {min,max}, {n}, or {n,}, and apply to examples like three-letter words, hex numbers, and Social Security numbers.
Revisit greedy and lazy quantifiers in JavaScript regular expressions, applying repetition rules to match two digits, a hyphen, and four to six digits, and observe how laziness changes matches.
Practice JavaScript regular expressions by validating a phone number as you type, matching formats with parentheses, hyphens, or periods, and turning the text green when valid.
Learn to validate a phone number in JavaScript using an immediately invoked function expression, a regex literal with optional parts, and keyup to toggle green or red classes.
Discover anchored expressions in JavaScript regular expressions, learning to constrain matches to the start or end of a string or word, and to set position parameters around a pattern.
Learn how the caret and dollar sign anchor matches at the start and end of a line. Explore how global, ignore-case, and multi-line flags shape these anchored matches.
Develop accurate regular expressions by narrowing patterns with digit ranges and anchors, making matches like five-digit and four-digit zip codes precise, and using groups to handle optional parts.
Apply the string wrapper's replace method on a text variable to substitute any day of the week with Monday in content.js. Display the results on the console.
apply a global, case-insensitive regular expression with word boundaries to replace every day of the week with monday, and log the result to the console.
Use the pipe symbol to express alternates in a regular expression, matching Monday, Tuesday, Sunday. Maintain word boundaries and use the ignorecase flag and global flag to ensure accurate matches.
Learn how grouping with parentheses sets precedence in JavaScript regular expressions and enables repeating groups to match patterns like A–D followed by 1–5, and to enforce word boundaries.
Learn how grouping in regular expressions captures year, month, and day from a date string with flexible separators, using the exact method in JavaScript to extract components without split.
Learn about capturing groups in regular expressions, how parentheses capture text for later use, how to reference them, and non-capturing groups like (?:) with examples.
Learn that group back references refer to captured text, not the pattern, and see how HTML examples use capturing versus non-capturing groups to validate matches.
Named capture groups were introduced in ECMAScript 2018 and are now widely supported.
Mastering regular expressions in JavaScript teaches lookahead groups to shape matches without capturing, with domain extraction before .com and password validation enforcing eight characters, uppercase, lowercase, and numbers.
Discover negative lookahead groups in regular expressions, illustrated by password validation, and review lookahead concepts, capture groups, non-capturing groups, and the regex cheat sheet.
Lookbehind groups were introduced in ECMAScript 2018 and are now widely supported.
Explore how named capture groups help solve a problem by labeling groups as first and last, then accessing them with groups.first and groups.last in JavaScript.
Learn how Unicode standardizes character representation, why encoding systems mattered, and how to use the \u escape sequence in regular expressions to represent characters, like 0065 for the letter E.
Learn how ES6 adds a Unicode flag to RegExp, enabling extended characters like the treble clef to be treated as single characters. See curly-brace hex notation and practical console examples.
Apply regular expressions with real examples to match criteria and practice using real life data. Pause, attempt each example, compare your result, and learn the different varieties of regular expressions.
Compare simple and strict email matching with regular expressions, detailing at symbols, domain dots, start and end of string, and character sets that exclude spaces.
Learn to replace text with regular expressions in JavaScript, using the global flag and capturing groups to swap name order and replace html tags like b with strong.
Craft a regex to validate an IP address in four dot-separated octets, each 0–255 with no leading zeros. Test and refine the pattern using RegEx Pal.
Learn to extract all numbers from a string using the string match method with a global regex, convert them with parse int, and sum them with reduce.
Discover how to retrieve the starting index, length, and actual match of a regular expression using the exec method on the regex itself, without using the global flag.
Regular expressions can help you more easily solve programming problems. They are an important tool in your coding toolbox. If you have dabbled with regular expressions or not even used them before, this course is for you. You will learn the syntax and participate in numerous examples and exercise to help you integrate regular expressions into your JavaScript code.
In Mastering Regular Expressions in JavaScript we focus on two main goals: Helping you learn regular expressions and construct them, and teaching you the powerful ways regular expressions can be used in JavaScript. If you work in the JavaScript language, this course will be most useful, but even if you work in another language you can use this course to learn about regular expressions as the syntax applies to many programming languages.
This course provides numerous opportunities to apply what is being taught. In fact one of the final sections is devoted to applying regular expressions, which basically presents different scenarios and then gives you a chance to solve them before going through it with the instructor.
This course contains 9 sections, over 60 different lectures, over 5 hours of video tutorials, 5 exercises, 5 quizzes and 12 application lectures that will make sure you have what you need to use regular expressions in your JavaScript coding work.
If you are ready to master regular expressions, this course is for you!