## Number Extractor

#### Number Extractor

#### Result Summary:

Type | Result |

Given Text | 0 |

Extracted Numbers | 0 |

### What is Number Extractor?

Number extractor is a tool to extract any number (integer or float types) from a line of text. This tool takes a line or paragraph of text (which is of string type) and lists out all the numbers present in this text. It works with both integer and float numbers, as well as negative numbers. Consider the following example

Text: “For this recipe, we need 1.5 tablespoons of oil, 2 eggs, and 1 cup of milk.” The number extractor tool will return the following as output: 1.5, 2, 1

The number extractor tool is very useful if the text is really long. For example, if we were to find all the phone numbers and register numbers of fifty students in a class from a list containing their names, register numbers and phone numbers, this tool would promptly list out the phone numbers along with the corresponding register numbers.

If the text provided as input does not contain any numbers, this tool would display “No numbers found” or a similar error message.

### Properties of Number Extractor

Given below are some important properties of the number extractor tool.

**Input text ** – The line or block of text which is entered as an input to the tool. The text may contain only numbers, or no numbers at all, or be a mix of both numbers and letters. If the text does not contain any numbers at all, the number extractor would not be able to find any numbers.

This tool also does not recognize fractions. For example, the text “We need ½ cup of water for the plant” would result in “1, 2” which is incorrect. Instead, the text should read “We need 0.5 cup of water for the plant” for the output to be “0.5”. The number extractor tool does not recognize the ‘/’ in fractions.

**Output numbers ** – The output obtained from a number extractor tool is always a number, be it an integer or a floating-point number. The tool also recognizes negative numbers. The lack of any numbers in the input text would result in an error message.

### Characteristics of number extractor

The number extractor tool has the following characteristics:

### The number extractor tool in use

We now consider a few examples making use of the number extractor tool.

__Input: __

The integers are 1, 4, 9, 16, 25, 36, 49. The floating-point numbers are 3.1416, 53.78907 and 2.718. The negative numbers are -1, -2, -3, -4, -5, -6, -7.

__Output: __

1, 4, 9, 16, 25, 36, 49, 3.1416, 53.78907, 2.7818, -1, -2, -3, -4, -5, -6, -7

__Input: __

The value of pi is 3.1416, the value of Euler’s number (e) is 2.718 and the value of acceleration due to gravity on Earth is 9.8 m/s^{2}.

__Output: __

3.1416, 2.718, 9.8

__Input: __

The recipe for brownies requires the following ingredients 1.5 cups powdered sugar, 0.75 cup flour, 2 large eggs, 0.5 cup dark chocolate chips and 0.5 teaspoon vanilla.

__Output: __

1.5, 0.75, 2, 0.5, 0.5

__Input: __

5 - 4 = 1, 5 + 4 = 9, 5 / 4 = 1.25, 5 × 4 = 20.

__Output: __

5, 4, 1, 5, 4, 9, 5, 4, 1.25, 5, 4, 20

__Input: __

The author of the book, Jurassic Park, is Michael Crichton.

__Output: __

No numbers found

### Areas of application

The number extractor is useful in the following cases: