Regular Expressions 101

Community Patterns

localhost match range ip with port number

-1

Regular Expression
Python

r"
^127\.\d{1,3}\.\d{1,3}\.\d{1,3}(\:\d+)?$
"
mg

Description

Matches all ips that points to localhost like, optionally capturing port number: 127.X.X.X and 127.X.X.X:<port>

Submitted by Rodrigo M. A. - 8 years ago