Remove Non Numbers

Learn how to remove non-numeric characters from your data using the regexreplace function in Google Sheets. This video guides you through the process of cleaning up your data for better usability.

So you wanna remove non-numbers. We wanna clean up our data , we wanna make it look nice, we want it to feel nice, and actually be nice. We want to remove symbols from, like, ID, or we want to strip symbols from a username. Sometimes if we're trying to create users and we have some types of, like, non-numbers and non-letters, we wanna strip all those. Or even we wanna turn some kind of currency, if we have this, like, information that we don't need. Here, we have, like, a dollar sign . We don't need it. We just want the raw number . Or we wanna clean up packaging labels, or we wanna, like, clean up file names that have just n- non-numbers and non-letters. Get rid of all those. This is how we do it.

We're gonna do equals regex , and there are three types of regular expression formulas. There's match , extract, and replace. Match just tells us if that exists. Extract says, "Just get that one out of there." But replace, which we're gonna use right now, regexreplace , is gonna say, "If you have it, replace it with this thing that I want you to replace it with." And in our particular case of removing non-numbers, we're gonna replace it with nothing. So we're gonna do regexreplace , and we're gonna have a little bit of a code here. This code is going to need the text, so we say B3, then comma, and then we're gonna need what are we searching for, which in quotes is going to be surrounded by square brackets.

And we're gonna say, actually, we have this little caret icon. On my laptop, it's above the six. On your laptop and keyboard, it might be different. It's sort of like a up arrow kind of thing, a caret or chevron. And now we're going to say anything that's not this. So th- this means not. Like, look for anything that's not these things. So we have three pieces of information that we need to give it, which is A hyphen Z, lowercase, and regex is very, very specific. So we need to also include capital A and capital Z with a hyphen. So this is saying, "Look for any lowercase letter and any uppercase

letter, but anything that's not those." But there's one more item we need to add in here, which is zero hyphen nine. These also include the numbers. So this is saying just letters, just numbers, but anything that's not that, and that's what that chevron over there is saying. And then we're saying, "Okay. What do we want out of this? When we find these things, what do we want to replace them with?" If I add a comma right away- I can see that this is correct. This is exactly what I want. I want nothing else. I just want to remove. I don't wanna replace with a space. I don't wanna replace with something else. I want to replace with nothing. And so I could leave this here like this, end parenthesis, but for completion's sake, I'm gonna add two quotes. Two quotes with no space in between them.

This is saying just replace everything that's not a letter and not a number with nothing. And end parenthesis and hit Enter. And I can copy and paste this down and I can see, oh, there's a value because it expects text value . Maybe I have this format wrong. I need to go and change it to plain text , and there it goes. But see also, just to be aware, it is also deleting this dot. So some currencies, uh, if you have these, like in US dollars, we have dot cents, dollars dot cents. But in some currencies, it is just like all commas like this. That's okay in this way, but you might be losing some data if you're really turning this con- this currency into just the raw numbers.

Just to be aware of that. Here's Apple box, Apple5 box, but it looks like Apple number five got rid of all of those. And we could copy and paste this down, Command+C, Command+V. There is one other thing we can do here to make our lives a little bit easier, is once we have one formula for regex replace, we can wrap it with array formula . Array formula gives us a superpower which says take this text that we're looking at, B3, and change it to B3 colon B. B3 colon B means look at the entire column from B third down. Hit Enter, and there's all of our results with one formula . I think that's really cool. I think these two formulas together are absolute magic. Re- regex replace and array formula.

Hope you enjoyed this video You are watching better sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is gonna be your next Google sheet.