Preface

Regular expressions are patterns or templates, which allow you to define a set of rules in a natural yet vague way, giving you the ability to match and validate text. They have, more or less, been implemented in nearly every modern programming language.

When working with any type of textual input, you don't always know what the value will be, but you can usually assume (or even demand) the format you are going to receive into your application. These types of situations are exactly when you would create a regular expression to extract and manipulate this input.

In this book, you will learn the basics to get started with a regular expression in JavaScript. We will start with the basics, passing through some special patterns and then, dive into two examples. The first one is validating a web form, and the second one is a very complex pattern to extract information from a log file. For all the examples, we will use a step-by-step approach, which will make it easier to learn and assimilate all the knowledge we've gained from this book.

What this book covers

Chapter 1, Getting Started with Regex, presents an introduction about regular expressions in JavaScript. It also shows how to develop the program that will be used to test the regular expressions used in the first three chapters.

Chapter 2, The Basics, covers the main features of regular expressions in JavaScript, which are vague matchers, multipliers, and ranges.

Chapter 3, Special Characters, dives into the special characters patterns of Regex. It covers defining boundaries for a Regex, defining nongreedy quantifiers, and defining Regex with groups.

Chapter 4, Regex in Practice, demonstrates how to develop a web form and validate all its fields using regular expressions functionalities learned since the first chapter.

Chapter 5, Node.js and Regex, explains step by step how to create a simple application using Node.JS to read and parse an Apache log file using Regex. It also demonstrates how to display the information from the log file into a friendly web page to the user.

Appendix, JavaScript Regex Cheat Sheet, presents a summary of the patterns used in regular expressions in JavaScript along with their descriptions, and a list of useful methods to test and create regular expressions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset