Help

Re: Formula for cutting out numeric values

Solved
Jump to Solution
2184 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Josh_Colina1
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there! This is a very newbie question, but is there a formula for cutting numbers out of a string? For example, if I have the value

01 Lorem ipsum

and I want it to read

Lorem ipsum

what formula would I use?

11 Replies 11

This is an important distinction between Ben’s formula and mine. Mine only removes digits at the start of the string. Ben’s removes all digits everywhere in the string.

Note that this can be problematic. What if there are two or more spaces next to each other that were in the original string that did not have digits between them? This formula will remove those additional spaces as well.

There are a few other options. Instead of using '\s{2,}' you could also use ' +' to find one or more spaces and replace them with a single space. This would have the same effect. It depends on what you find easier to read and how much work you want the computer to use.

However, another option would be when searching for digits to search for one or more digits and zero or more trailing spaces in the initial REGEX_REPLACE: '\d+ *. This would leave any consecutive spaces that were supposed to be there unaffected.

I agree. A regex tester is essential to learning regex. However, I find that different regex testers have different helps, so if one doesn’t work for you, try a different website.

There are many ways to do things in REGEX. Testing with a wide variety of inputs is essential to getting the result you want.

How does one also extract the numbers that are mixed with texts in the middle?