In this video, I cover the JavaScript function replace(). The function allows you to search for a string (by matching a regular expression) and replace that string. The replacement can be a literal string itself or you can pass in a callback where you can use logic and programming to generate a replacement string based on anything you can imagine.

This is the ninth video in a series on Regular Expressions, which is part of the “Programming from A to Z” course at ITP (

Next Video:

Course url:

Support this channel on Patreon:

Send me your questions and coding challenges!:


GitHub Repo with all the info for Programming from A to Z:

Links discussed in this video:
MDN’s Regular Expressions Reference:
Regular Expressions on Wikipedia:
Book Mastering Regular Expressions:
ITP from Tisch School of the Arts:

Source Code for the all Video Lessons:


For More Programming from A to Z videos:

For More Coding Challenges:

Help us caption & translate this video!