Hello everyone, in this article, we will show you how to use Replace function in the QGIS field calculator. The Replace function is commonly used for strings or text. In QGIS, we can use the Replace function inside the Field Calculator to replace some portions of the text with other text or characters.
The replace function uses the following syntax:
replace (string, before, after)
In the following table, you can see the Test column contains the text. We will try to replace the “m” with “meter“.
First, let’s, open the Field Calculator. And then, you will need to decide how we are going to treat our data. We can replace the existing column with the new data or we can also create a new column/field for our new data. In this example, I will replace the content of my Test column with the new data.
Check the Update existing field if we want to update the existing column with the updated data. And then, type the expression in the expression editor window. In this case, I will replace ‘m’ with ‘meter’, so I use the following syntax.
replace ("Test", 'm', 'meter')
Modify the syntax with your own. Now, the result will look like this.
Thanks for reading this article on how to use replace function in QGIS. See you in the next GIS tutorials.