DEV Community

Discussion on: The Complete Guide to Regular Expressions (Regex)

Collapse
 
blitzdex27 profile image
Dekstur

Hello, I think you missed something here. I tried your code and the output is : "Goodbye, Goodbye there!". By the way, thanks for sharing! This materials is easier to learn.

let str = "Hello, hi there!";
str = str.replace(/[Hh]ello|[Hh]i|[Hh]ey/g, "Goodbye");
console.log(str); // Will output "Goodbye, hi there"

Collapse
 
crutchcorn profile image
Corbin Crutchley

Whoops! Yup, it should be "Goodbye, Goodbye there!" for sure. I'll update that.

Thanks for reading and letting me know!

Collapse
 
blitzdex27 profile image
Dekstur

No problem! it was a good read. Thanks too!