Regular Expression Part 1 : Introduction

Swarnali Roy - Jul 24 '21 - - Dev Community

Hello readers!
In this blog , I am going to write about JavaSript Regular Expressions, also commonly known as REGEX. This is the first part of this series.

Let's get introduced with Regular Expressions đź“–

REGEX is an object that describes a certain pattern of characters which is used to perform pattern-matching , find, search and replace functions on text or strings. It is also very important when we want to validate emails, usernames or passwords.

Basic Syntax

The basic syntax of a regex is : /pattern/

A very simple example of searching a regex in a string is, you simply have to write your desired pattern inside the / /.

let testStr = "Search the word regex in this string";
let testRegEx = /regex/;
Enter fullscreen mode Exit fullscreen mode

In this introduction part, I want to leave it just to the basic syntax. In the next part, we will learn how to search a regex within a string.

. . . . . . . . . . . . . . . . . . . . . .