InRegex Logo
InRegex
New

Match IP Address in JavaScript

Explanation

This regex pattern matches an IP address in the format 'xxx.xxx.xxx.xxx', where each 'xxx' can be a number between 0 and 255. The '\b' ensures that the match is a whole word.

javascript

Regular Expression

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

Example Usage

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

Similar Regular Expressions