EasyRegex Logo
EasyRegex
New

Match a Number in JavaScript

javascript

Regular Expression

\d+
Copy
Do you have Feedback?

Explanation

This regex pattern \d+ will match any sequence of one or more digits (0-9).

javascript

Example Usage

const pattern = /\d+/g;
const testString = 'The number is 42';
const numbers = testString.match(pattern);
console.log(numbers);
Copy
Test the expression

Similar Regular Expressions