Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
(((2[0-5][0-5])|(1[0-9][0-9])|([1-9][0-9])|([0-9]))\.){3}((2[0-5][0-5])|(1[0-9][0-9])|([1-9][0-9])|([0-9]))
"
gm

Description

写一个正则表达式判断一个字符串是否是ip地址

规则:一个ip地址由4个数字组成,每个数字之间用.连接。每个数字的大小是0-255 例如:255.189.10.37 正确 256.189.89.9 错误

Submitted by anonymous - 4 years ago