DeskKit

Regex library

Regular expression for IPv4 addresses

A JavaScript regex for IPv4 dotted quads that rejects octets above 255. Test 127.0.0.1, private ranges, and invalid addresses.

^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$

Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.

Flags

Highlighted matches

    How to use

    1. Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
    2. Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
    3. Paste your own corpus. Nothing is sent to a server.
    4. Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.

    An IPv4 address is four octets, 0–255, separated by dots. A naive \d{1,3} pattern will happily accept 999.1.1.1. This one constrains each octet so 256.0.0.1 fails.

    It does not decide whether the address is public, private, or a bind-all 0.0.0.0. That is a policy check after the match.

    What this pattern will not do

    Leading zeros such as 127.000.000.001 still match the numeric ranges; reject them separately if you need canonical form.

    IPv6-mapped IPv4 (for example ::ffff:127.0.0.1) will not match; use the IPv6 pattern.

    FAQ

    Does this match CIDR like 10.0.0.0/8?

    No. Anchor the quad, then optionally add (\/(?:3[0-2]|[12]?\d))? if you need CIDR.

    Is 127.0.0.1 allowed?

    Yes. Loopback is a valid IPv4 address.

    Is the sample text uploaded?

    No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.

    DeskKit is a static site. Interactive tools require JavaScript.