if you know for sure that there are only going to be 2 places where you have a list of digits in your string and that is the only thing you are going to pull out then you should be able to simply use

\d+
Answer from Seattle Leonard on Stack Overflow
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-extract-numbers-from-a-string-using-regular-expressions
How to extract numbers from a string using regular expressions?
November 21, 2019 - Enter sample text: this is a sample 23 text 46 with 11223 numbers in it Digits in the given string are: 23 46 11223 ยท import java.util.regex.Matcher; import java.util.regex.Pattern; public class Just { public static void main(String[] args) { String data = "abc12def334hjdsk7438dbds3y388"; //Regular expression to digits String regex = "([0-9]+)"; //Creating a pattern object Pattern pattern = Pattern.compile(regex); //Creating a Matcher object Matcher matcher = pattern.matcher(data); System.out.println("Digits in the given string are: "); while(matcher.find()) { System.out.print(matcher.group()+" "); } } }
Discussions

How to extract numbers within a string?
You want to look into regular expressions (regex) and Python's re module . import re string = "CORSAIR VENGEANCE RGB 16GB (2X8GB) DDR4 3200MHZ CL 16" matches = re.findall("(\d+)", string) print(matches) Output: ['16', '2', '8', '4', '3200', '16'] The regex pattern \d+ matches 1 or more numerical characters in sequence. By putting it in brackets ( ) it captures each occurrence of that pattern as a group. And the re.findall method returns those groups in a list. Note that they are still strings, not numbers. More on reddit.com
๐ŸŒ r/learnpython
17
38
January 7, 2018
Please help me with a RegEx to extract only the numbers from a string variable
Hi, I have a string variable which contains both text and numbers assigned to a string variable. I want to extract the numbers from the string using RegEx. Example: If the text is โ€œText#$1234โ€, I want to extract โ€œ1234โ€ alone Thanks More on forum.uipath.com
๐ŸŒ forum.uipath.com
6
1
March 12, 2024
Extract numbers from text with Regex
Hi everyone, Iโ€™m trying to get (xx) x xxxx-xxxx return only xxxxxxxxxxxx with regex pattern can anyone help me? More on forum.bubble.io
๐ŸŒ forum.bubble.io
2
1
April 4, 2023
Regex to extract string and number
Help me please to create a regex to extract string and number from a string like 906D3829.22 into 906 D 3829.22 So far, I have been able to extract numbers using [\d.]+ into 906 3829.22 More on community.alteryx.com
๐ŸŒ community.alteryx.com
June 11, 2022
๐ŸŒ
DevQA
devqa.io โ€บ extract-numbers-string-java-regular-expressions
Extract Numbers From String Using Java Regular Expressions
February 11, 2020 - The following Java Regular Expression examples focus on extracting numbers or digits from a String. import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExamples { public static void main(String[]args) { Pattern p = Pattern.compile("\\d+"); Matcher m = p.matcher("string1234more567string890"); while(m.find()) { System.out.println(m.group()); } } } Output: 1234 567 890 ยท
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-regex-extract-find-all-the-numbers-in-string
Python RegEx โ€“ Extract or Find All the Numbers in a String
In this example, we extract numbers from the string 'We live at 9-162 Malibeu. My phone number is 666688888.'. import re str = 'We live at 9-162 Malibeu. My phone number is 666688888.' # Extract numbers using regex numbers = re.findall('[0-9]+', str) print(numbers)
๐ŸŒ
R-bloggers
r-bloggers.com โ€บ r bloggers โ€บ extracting numbers from strings in r
Extracting Numbers from Strings in R | R-bloggers
June 11, 2024 - # Extract numbers using stringi numbers <- stri_extract_all_regex(text, "\\d+") # Convert to numeric numeric_result <- as.numeric(unlist(numbers)) print(numeric_result) [1] 45 50 ยท Explanation: stri_extract_all_regex(text, "\\d+") extracts ...
๐ŸŒ
Learning About Electronics
learningaboutelectronics.com โ€บ Articles โ€บ How-to-extract-numbers-from-a-string-in-Python-using-regular-expressions.php
How to Extract Numbers from a String in Python Using Regular Expressions
This is the same exact code as above, but just a different string that contains multiple numbers, this time. The code, above, returns the following output. So you see that Python just returns the numbers as a list. So this is extracting numbers (or digits) from a string in Python using regular expressions.
Find elsewhere
๐ŸŒ
UiPath Community
forum.uipath.com โ€บ help โ€บ studio
Please help me with a RegEx to extract only the numbers from a string variable - Studio - UiPath Community Forum
March 12, 2024 - Hi, I have a string variable which contains both text and numbers assigned to a string variable. I want to extract the numbers from the string using RegEx. Example: If the text is โ€œText#$1234โ€, I want to extract โ€œ1234โ€ โ€ฆ
๐ŸŒ
Octoparse
octoparse.com โ€บ blog โ€บ regex-how-to-extract-all-phone-numbers-from-strings
RegEx: How to Extract All Phone Numbers from Strings | Octoparse
July 10, 2022 - This article shows you how to extract phone numbers from large strings by using regular expressions.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ find-all-the-numbers-in-a-string-using-regular-expression-in-python
Find all the numbers in a string using regular expression in Python - GeeksforGeeks
May 8, 2023 - ... Approach: The idea is to use Python re library to extract the sub-strings from the given string which match the pattern [0-9]+. This pattern will extract all the characters which match from 0 to 9 and the + sign indicates one or more occurrence ...
๐ŸŒ
Regex Pal
regexpal.com โ€บ 99837
Extract Number - Regex Pal
Url checker with or without http:// or https:// Match string not containing string Check if a string only contains numbers Only letters and numbers Match elements of a url date format (yyyy-mm-dd) Url Validation Regex | Regular Expression - Taha Match an email address Validate an ip address nginx test Extract String Between Two STRINGS special characters check match whole word Match or Validate phone number Match anything enclosed by square brackets.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-extract-numbers-from-string
Python | Extract Numbers from String - GeeksforGeeks
November 10, 2025 - re.findall() function searches the text and finds all number patterns using regex, making it an easy way to extract all numbers at once. It can extract positive, negative, and decimal numbers.
๐ŸŒ
Bubble
forum.bubble.io โ€บ need help
Extract numbers from text with Regex - Need help - Bubble Forum
April 4, 2023 - Hi everyone, Iโ€™m trying to get (xx) x xxxx-xxxx return only xxxxxxxxxxxx with regex pattern can anyone help me?
๐ŸŒ
Bardeen
bardeen.ai โ€บ answers โ€บ how-to-extract-numbers-from-a-cell-in-google-sheets
Extract Numbers from Strings in Google Sheets: A Guide
March 6, 2024 - In this formula, A1 is the cell ... extraction and data cleanup: Extracting numbers from a string with currency symbols and commas: =REGEXREPLACE(A1, "[^0-9\.]", "")...
๐ŸŒ
Alteryx Community
community.alteryx.com โ€บ home โ€บ participate โ€บ discussions โ€บ alteryx one
Regex to extract string and number - Alteryx
June 11, 2022 - Help me please to create a regex to extract string and number from a string like 906D3829.22 into 906 D 3829.22 So far, I have been able to extract numbers using [\d.]+ into 906 3829.22
๐ŸŒ
Microsoft Support
support.microsoft.com โ€บ en-us โ€บ office โ€บ regexextract-function-4b96c140-9205-4b6e-9fbe-6aa9e783ff57
REGEXEXTRACT Function | Microsoft Support
REGEXEXTRACT always return text values. You can convert these results back to a number with the VALUE function. Copy the example data and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data. Extract names based on capital letters with pattern "[A-Z][a-z]+"
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ extract-a-number-from-a-string-using-javascript
Extract a Number from a String using JavaScript - GeeksforGeeks
The number from a string in JavaScript can be extracted into an array of numbers by using the match method. This function takes a regular expression as an argument and extracts the number from the string.
Published: July 11, 2025
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 547128 โ€บ java โ€บ Extract-number-regular-expression
Extract a number using regular expression? (Beginning Java forum at Coderanch)
July 27, 2011 - The regex Jeanne was hinting at will allow you to, with a loop, get 12, 52 and 365 all separately. SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6 How To Ask Questions How To Answer Questions ... If your String always contains only one (1) group of digits, you could approach this from the opposite end and remove all non-digits with the Regex \D Which would return 1252365 for the sentence "A year has 12 months, 52 weeks and 365 days".
๐ŸŒ
Spreadsheet Point
spreadsheetpoint.com โ€บ home โ€บ google sheets tips โ€บ how to extract numbers from a string in google sheets
How to Extract Numbers from a String in Google Sheets
June 30, 2021 - If you want to extract more than one numeric digit from the start of the string, you can use the expression โ€˜^d+โ€™. Now what happens if the string does not start with a number at all? In that case, the REGEXEXTRACT function returns an error.