Python 正则表达式验证IPv4地址

来源:互联网 发布:怎么查自己的淘宝账号 编辑:程序博客网 时间:2024/06/06 02:35
1. Simple regex to check for an IP address^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$2. Accurate regex to check for an IP address, allowing leading zeros^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$3. Accurate regex to check for an IP address, disallowing leading zeros^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$4. Simple regex to extract IP address from longer text\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b5. Accurate regex to extract IP addresses from longer text, allowing leading zeros\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b6. Accurate regex to extract IP addresses from longer text, disallowing leading zeros\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b7. Simple regex that captures the four parts of the IP address^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$8. Accurate regex that captures the four parts of the IP address, allowing leading zeros^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$9. Accurate regex that captures the four parts of the IP address, disallowing leading zeros^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$

0 0
原创粉丝点击