Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Java 8

"
^((?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?:\.(?!\:)|)){4})\:(?!0)(\d{1,4}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$
"
g

Description

This regex matches a IPv4 with a TCP Port (1-65535) Example: 192.168.0.69:1337 will match and have the groups:

  • Group 1: 192.168.0.69
  • Group 2: 1337
Submitted by SIMULATAN - 3 years ago