REGEXREPLACE
Description
Replaces parts of a string by matching to a pattern.
Syntax
REGEXREPLACE(
text
,
regex
,
replacement
, [
ignore_case
])
- text: The text to search.
- regex: The regular expression.
- replacement: The text to insert.
- ignore_case: If TRUE, the function ignores case when searching. If FALSE, the function considers case. The default is FALSE.
Example
Formula | Result |
|---|---|
=REGEXREPLACE(A1,"^0$"," ")
Where cell A1 contains
0
.
| (Blank in cell) |
=REGEXREPLACE(A1,"\n"," ") Where cell A1 contains: Text with a line break | Text with a line break |
=REGEXREPLACE(A1, "\(([A-Za-z]+)\)", "(yearly)")
Where cell A1 contains
Check total (monthly)
.
| Check total (yearly) |
=REGEXREPLACE(A1,"[0-9]+","5250")
Where cell A1 contains
6000:Salaries and Wages
.
| 5250:salaries and wages |
=REGEXREPLACE(A1,"[0-9]*\.[0-9]+[0-9]+","2500.00")
Where cell A1 contains
Total for 2017 is $2451.00
.
| Total for 2017 is $2500.00 |
Related Functions
REGEXFIND
REGEXPARSE