1:32 In this case the company tag and we will replace that with the bonsaiilabs as the replacement string. Now what we'll do, we'll console.log of this result because replace gives you a new string and let's run it now. We will see that the first replacement has happened. The company has been changed to bonsaiilabs but the second replacement and did not happen. It is still the company tag. Why? If you head over to the documentation of string dot replace, you will find a section where it says if a pattern is a string only the first occurrence will be replaced and that explains why the company tag was replaced just one with the bonsaiilabs and not the second one. Okay, so what do we do so that all the company tags get replaced with the company name of our choice. We are going to make use of regular expressions here. So we'll create a variable called regex and between two forward slash we will identify what pattern we want to find and then we will use the emailtemplate.replace method by passing in the regular expression as the first argument which is what we have to find and bonsaiilabs as the second argument with what we need to replace. We will run the console.log of the new string that is returned by replace and when we run it you will see that the first pattern has been replaced but the second part is still sitting at the company tag.
2:55 It has not been replaced. It is because string dot replace method on regular expression is also changing only the first occurrence and not all of them. So how do we tell the regular expression to make the changes to all the company tags and not just the first one? In order to do that, we will indicate that our regular expression is a global search. You do that by putting a G after the second forward slash on a regular expression, and once we clean and run it again, you would see now that both the patterns have been replaced by the bonsaiilabs as the company name. Now what if our From tags have inconsistencies in the casing? So for example, instead of company as a small C, we have a capital C in the second pattern. Now would this code work? Let's find out. So we clean and when we run it, you would see that the first pattern has been replaced, but the second pattern has not.