Launching a SaaS?·Collect waitlist signups before you build — before.run
SandboxPatternsDetectDocsChangelog
Network
#port
#network
#tcp
#udp

Port Number

Matches a valid TCP/UDP port number from 0 to 65535.

Server configurationNetwork firewall rulesURL parsing
/
/
Safe
Test String
6 matches
(…)Group #1Capturing group — captures matched text for reuse or extraction
66'6' — literal character
55'5' — literal character
55'5' — literal character
33'3' — literal character
[…]Character class […]Matches any single character listed in this set
||| — alternation: matches expression on left OR right
66'6' — literal character
55'5' — literal character
55'5' — literal character
[…]Character class […]Matches any single character listed in this set
\ddigit\d — digit (0–9)
||| — alternation: matches expression on left OR right
66'6' — literal character
55'5' — literal character
[…]Character class […]Matches any single character listed in this set
\d{2}digit\d — digit (0–9) — repeated exactly 2 times · {2} — exactly 2 times
||| — alternation: matches expression on left OR right
66'6' — literal character
[…]Character class […]Matches any single character listed in this set
\d{3}digit\d — digit (0–9) — repeated exactly 3 times · {3} — exactly 3 times
||| — alternation: matches expression on left OR right
[…]Character class […]Matches any single character listed in this set
\d{4}digit\d — digit (0–9) — repeated exactly 4 times · {4} — exactly 4 times
||| — alternation: matches expression on left OR right
[…]Character class […]Matches any single character listed in this set
\d{0,3}digit\d — digit (0–9) — repeated between 0 and 3 times · {0,3} — between 0 and 3 times
||| — alternation: matches expression on left OR right
00'0' — literal character
Pattern: 73 charsInput: 24 chars
100% client-side · private

Valid Examples

  • 80
  • 443
  • 8080
  • 3000
  • 65535
  • 0

Invalid Examples

  • 65536
  • 99999
  • -1
  • abc

Usage & Integration

Validate Port Number natively in your backend or frontend without copying regex strings.

Node / Edge

import { validate } from '@regexto/validators';

validate('port-number', '...');

Python

from regexto_validators import validate

validate("port-number", "...")

Go

import "github.com/regex-to/validators-go"

valid, err := validators.Validate("port-number", "...")

PHP

use RegexTo\Validators\Validator;

Validator::validate('port-number', '...');

Rust

use regexto_validators::validate;

let is_valid = validate("port-number", "...").unwrap();