---
title: "Discussion on \"Regular Expressions in JavaScript.\" | Hashnode"
description: "Discussion on \"Regular Expressions in JavaScript.\". Regular Expressions, popularly known as Regex, I think gets a bad rep for being tricky or especially difficult to understand or apply. It has been a muse for tech memes, but you don't always have to relate to all of that, this article is here to help..."
url: "https://hashnode.com/posts/regular-expressions-in-javascript/5f7a4ca09c3b6e4101217b16"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Regular Expressions in JavaScript.](https://amara.hashnode.dev/regular-expressions-in-javascript?utm_source=hashnode&utm_medium=feed)

Regular Expressions, popularly known as Regex, I think gets a bad rep for being tricky or especially difficult to understand or apply. It has been a muse for tech memes, but you don't always have to relate to all of that, this article is here to help...

Oct 4, 2020 · 5 min read · amara.hashnode.dev  
Updated Jul 30, 2021  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#regex](https://hashnode.com/tag/regex)

## Written by

[Amarachi Iheanacho](https://hashnode.com/@Amara)

@Amara · Lagos, Nigeria

  
[View profile](https://hashnode.com/@Amara)

Frontend Developer

All things Frontend web development.

## Responses 2

Markdown supported · ⌘↵ to post

[Reehan](https://hashnode.com/@the-accidental-dev)

[Oct 6, 2020](https://hashnode.com/posts/regular-expressions-in-javascript/5f7a4ca09c3b6e4101217b16/comment/5f7bc289e93896601dd2908b)

Hey, firstly, great article!

However, in your regex replace example, I believe something's missing?

Running the following will throw an error: `Uncaught ReferenceError: str is not defined`

```
var heyStr = "Hey now!";
var byeStr = "Bye";
var res = str.replace("Hey", "Bye")//returns ;
```

Shouldn't `res` = `heyStr.replace("Hey", "Bye")` ?

Similarly, the str.search() example is missing. Let me know if I'm missing something?

[Amarachi Iheanacho](https://hashnode.com/@Amara)

[Oct 11, 2020](https://hashnode.com/posts/regular-expressions-in-javascript/5f7a4ca09c3b6e4101217b16/comment/5f7bc289e93896601dd2908b#reply-5f8255bf7762251b305d957a)

Hey, thank you Reehan, I have fixed it now, please check it out.

[Chimdia Anyiam](https://hashnode.com/@chimdia)

[Oct 4, 2020](https://hashnode.com/posts/regular-expressions-in-javascript/5f7a4ca09c3b6e4101217b16/comment/5f7a4f847d160d41227d8ab6)

Really helpful article!

[Amarachi Iheanacho](https://hashnode.com/@Amara)

[Oct 4, 2020](https://hashnode.com/posts/regular-expressions-in-javascript/5f7a4ca09c3b6e4101217b16/comment/5f7a4f847d160d41227d8ab6#reply-5f7a540d7d160d41227d8ae7)

Thank you Chimdia
