Premium Google Sheets drill · Text and regular expressions
REGEXREPLACE a phone down to digits
Practice Google Sheets REGEXREPLACE to strip every non-digit from a phone number while keeping the digit text.
A2 is a phone number with parentheses, spaces, and a hyphen. REGEXREPLACE swaps every match for new text.
In B2, replace every character that is not a digit with an empty string.
Dataset
Starter sheet. Cells marked formula are where the formula goes.
| Row | A | B |
|---|---|---|
| 1 | Phone | |
| 2 | (512) 555-0198 | Formula goes in B2. formula |
Hint
The pattern [^0-9] means any character that is not a digit from 0 to 9.
Explanation
Parentheses, spaces, and the hyphen all match [^0-9] and are removed. The digits stay text, so 5125550198 is not converted by SPLIT-style number parsing.
The interactive sheet and a worked solution are part of Formula Drills Premium. The instructions and starter data on this page are the full problem.