REGEXREPLACE in Google Sheets
Replaces every part of a text that matches a pattern with new text.
Syntax
REGEXREPLACE(text, regular_expression, replacement)- text
- The text to search. It must be text; a number gives #VALUE!.
- regular_expression
- The pattern in quotes, such as "\d+" for one or more digits.
- replacement
- The text to put in its place. "" deletes what matches.
Examples
C1
=REGEXREPLACE(1A2,2"\D",3"")| A | B | C | |
|---|---|---|---|
| 1 | Phone | 02079460018 | |
| 2 | Tel: 020 7946 0018 |
In plain words: In 1the phone number in A2, replace 2everything that is not a digit with 3nothing.
C1=REGEXREPLACE(A2,"\s+"," ")
| A | B | C | |
|---|---|---|---|
| 1 | Name | Ann Berg | |
| 2 | Ann Berg |