EasyRegex Logo
EasyRegex
New

Match IP Address in JavaScript

Javascript

Regular Expression

\b(?:\d{1,3}\.){3}\d{1,3}\b
Copy
Do you have Feedback?

Explanation

This regex pattern matches an IP address by looking for 4 groups of 1 to 3 digits separated by periods. The \b ensures that it matches whole words only.

Javascript

Example Usage

const regex = /\b(?:\d{1,3}\.){3}\d{1,3}\b/; 
const ipAddress = '192.168.0.1'; 
console.log(ipAddress.match(regex));
Copy
Test the expression

Similar Regular Expressions