Name

replaceall — Return a string replacing all occurrences of one substring with another.

Syntax

replaceall(string, find, replace)
              

The REPLACEALL function has the following arguments:

string

The string to search and replace.

find

The substring to find. The find string is interpreted as a regular expression so take care with special characters.

replace

The replacement string.

Description

Replaces all occurrences of the find string with the replacement string.

The find string is interpreted as a regular expression, so care must be taken when trying to match to special meta characters.

See the section on Regular expressions for a description of the matching patterns.

Examples

Formula

Description

Result

replaceall('ho ho ho', 'ho', 'hey')

Replace all of the 'ho' string with 'hey'.

'hey hey hey'

replaceall('Hot Pot Pit', '.ot','A')

Replace substring that matches with the.regular expression.

'A A Pit'

replaceall('((((', '\(','[')

Escape a meta character in the regular expression.

'[[[['

replaceall('Hello World', 'a', 'A')

When the find expression does not match then nothign changes.

'Hello World'