
Learn to use regular expressions in JavaScript with regex object methods (test, exec) and string methods (match, search, replace, split) through examples.
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'.
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.
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.
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.
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.
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.
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.
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 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.
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!