To extract number 9999 we can use the following code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExamples { public static void main(String[]args) { Pattern pattern = Pattern.compile("numFound=\" ( [0-9]+)\""); Matcher matcher = pattern.matcher(""); if (matcher.find()) { System.out.println(matcher.group(1)); } } } You may use itertools.groupby() along with str.isdigit() in order to extract numbers from string as: from itertools import groupby my_str = "hello 12 hi 89" l = [int(''.join(i)) for is_digit, i in groupby(my_str, str.isdigit) if is_digit] REGEXREPLACE will allow us to replace/extract ALL text, numbers, or special characters from a string, where REGEXEXTRACT will allow us to extract SUBSTRINGS of text, numbers, and special characters. Regular expression for extracting a number is (/ (\d+)/). 1,120.01) ? Parameters pat str. * (part 4). Great works a treat. input such as: "d158ghj1234567890sty" or "brf7nb889k1234567890deuh" output: "1234567890" Ana - Thursday, April 14, 2011 8:28:45 AM; I want to fetch number from my string Example: my string is "Mr. albert jhon 3423211 bot besan uk" i want to seprate the number 3423211 .. This function takes a regular expression as an argument and extracts the number from the string. By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. I guess _ in there means to look for numbers only after the underscore? From the end of the string, match zero or more non-digit characters, Match (and capture) one or more digit characters, Match all the characters to the start of the string. You must have JavaScript enabled in your browser to utilize the functionality of this website. Powerful, free, and fast. for version number string. How I can Extract last 10 Numbers form end of string? However, surrounding it with match-all other does work (.*?[0-9].*). Can anti-radiation missiles be used to target stealth fighter aircraft? 0. apex regex validation. Regular Expressions: Is there an AND operator? How do you use a variable in a regular expression? How can I visit HTTPS websites in old web browsers? My Item is: String HeatPump_Heizstab "Betriebsstunden ZWE1 [%s]"