Understanding RegEx in JavaScript (the easy way)

Understanding RegEx in JavaScript (the easy way)

Expressions, in detail, may sound incredibly scary at first… In JavaScript regular expressions can be defined in two ways. what is a RegEx? A regular expression is a explained of characters that define a search pattern. Understanding RegEx in JavaScript (the easy way) Regular

Don’t get scared by RegEx! They are easier than you think!

In computer science, some topics may sound scarier than others. Regular Expressions, in detail, may sound incredibly scary at first… but once you got it, you’ll find ’em incredibly easy and useful!

Why do I need RegEx?

First of all: what is a RegEx? A Regular Expression is a sequence of characters that define a search pattern.

Let’s take an example: we have a string containing both numbers and letters, and we want to delete every non-letter character.

let myString = "j18av228asc839ript329 r929o28ck1s22!";

How can we delete every number from this string? This doesn’t feel like a great solution:

let myString = "j18av228asc839ript329 r929o28ck1s22!";

function deleteNumbers(string) {
  let newString = "";
  for (let i = 0; i < string.length; i++) {
      if (isNaN(parseInt(string[i]))) {
        newString += string[i];

  return newString;

// => "javascript rocks!"

Of course, the code above would work… but I think that we could do better using a simple RegEx:

nodejs computer-science javascript regex

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Decoding Nodejs

The main goal of this blog is to explain the “Architecture of Nodejs” and to know how the Nodejs works behind the scenes. Generally, most of the server-side languages, like PHP, ASP.NET, Ruby, and including Nodejs follows multi-threaded architecture. That means for each client-side request initiates a new thread or even a new process.

Hire NodeJs Developer

Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

Hire dedicated JavaScript Developers who are proficient in AngularJS, ReactJS, NodeJS, & VueJS frameworks. Get flexible hiring models as per your business requirements.

Understanding Abstraction in Computer Science

This article is an introduction to abstraction in general. The content presented here applies to several sciences other than software engineering.

How To Build A Data Science Career In 2021

In Conversation With Dr Suman Sanyal, NIIT University,he shares his insights on how universities can contribute to this highly promising sector and what aspirants can do to build a successful data science career.