~/regex-tester

Match IPv4 addresses with regex

A loose IPv4 pattern that catches dotted-quads and a strict variant that rejects 999.999.999.999. Pick the one that matches your validation budget.

# pattern

/\b(?:\d{1,3}\.){3}\d{1,3}\b/g

→ Open in regex tester (pre-filled)

# how it works

Three groups of one-to-three digits followed by dots, then one final group. Word boundaries (`\b`) prevent matching inside longer strings. This is the *loose* form — it accepts 999.999.999.999.

# sample input

router 192.168.1.1 dns 8.8.8.8 garbage 999.999.999.999 internal 10.0.0.1

# pitfalls

# other patterns