13 Steps to become a JavaScript Pro. Step 7: Regular Expressions

Vincenzo Bifano
2 min readMar 4, 2023

--

Mastering Regular Expressions: The Essential Step 7 to Becoming a JavaScript Pro.

JavaScript is a popular programming language used to create dynamic and interactive websites. To become proficient in JavaScript, there are several topics to delve into, which this series aims to cover in a non-exhaustive way as a starting point for learning and improving.

Step 1, The Fundamentals is here
Step 2, Understanding the DOM is here
Step 3, Arrays and Objects is here
Step 4, Functions and Scope is here
Step 5, Events and Event Listeners is here
Step 6, Loops and Iteration is here

Regular expressions are a powerful tool in JavaScript for working with strings. They are used to match patterns in strings, which is useful for tasks like searching and validating text input. Here are some important topics to learn about regular expressions:

  1. Syntax: Regular expressions have their own syntax for specifying patterns. You’ll need to learn how to use characters like ., *, +, ?, and { } to match different types of characters and repetitions.
  2. Flags: In JavaScript, regular expressions can have flags that modify their behavior. For example, the g flag makes a regular expression match all occurrences of a pattern in a string, rather than just the first occurrence.
  3. Methods: JavaScript has several built-in methods for working with regular expressions, including test(), exec(), and match(). These methods allow you to check if a pattern matches a string, extract matched patterns from a string, and more.
  4. Lookahead and lookbehind: Lookahead and lookbehind are advanced regular expression features that allow you to match patterns based on what comes before or after them in the string. These can be useful for more complex matching tasks.
  5. Best practices: Regular expressions can quickly become complex and hard to read, so it’s important to follow best practices for creating and using them. This includes testing your regular expressions thoroughly, using comments to explain their purpose, and breaking them down into smaller, more manageable patterns.

Here are 5 useful links for learning about regular expressions in JavaScript:

  1. MDN Web Docs — Regular expressions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
  2. RegExr — Regular expression tester and debugger: https://regexr.com/
  3. Regular Expressions 101 — Online regular expression tester: https://regex101.com/
  4. JavaScript RegExp Object — W3Schools: https://www.w3schools.com/jsref/jsref_obj_regexp.asp
  5. Mastering Regular Expressions — Book by Jeffrey Friedl: https://www.amazon.it/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124

Note: If you make a purchase by clicking on the links I have provided, as an Amazon Associate I earn from qualifying purchases.

Step 8: Asynchronous JavaScript— coming soon. Follow me to know when it will be online

--

--

Vincenzo Bifano

Husband and father of two rough guys. Grace addicted. Senior Software Architect at Rai Radiotelevisione Italiana. I'm still in beta.