Description
In this article, you will learn how to use regular expressions or regex to replace a particular word in a string or remove certain characters/digits from a string.
Instructions
Here are two examples of how to do that.
A) Replacing a word in a string
For this example, imagine you want to replace the term "blue" with "red" in the following sentence:
1. Select the "Calculate a value" option and type str.replace(/blue/g, "red")
.
2. As a result, the new string must look like this:
Have a look at the following example and imagine you want to delete the digits from the string. Follow the steps below:
1. Select the "Calculate a value" option and type str.replace(/[0-9]/g, '')
2. As a result, the new string must look like this: