Toolbox-XToolbox-X

Extract Numbers

Extracts all numeric substrings from a given string and returns them as an array of numbers.

extractNumbersFromString

The extractNumbersFromString function extracts all numeric substrings from a given string and returns them as an array of numbers.

Function Signature

function extractNumbersFromString(input: string): number[]

Parameters

  • input (string): The string to extract numbers from.

Return Value

  • number[]: An array of numbers extracted from the input string. If no numbers are found, returns an empty array.

Example Usage

playground.ts

Notes

  • This function only matches unsigned integers (whole digits). It does not extract floating-point numbers or negative signs.

Aliases

The following aliases can be used for the extractNumbersFromString function:

  • extractNumbers
  • parseNumbersFromText

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page