当前位置:网站首页>Regular filtering of Intranet addresses and segments
Regular filtering of Intranet addresses and segments
2022-04-23 16:40:00 【GokuCode】
1. Problem description
I want to filter out ABC Intranet address and CIDR Format Intranet IP paragraph
Mainly the following paragraphs
1.A Class address :10.0.0.0~10.255.255.255
2.B Class address :172.16.0.0 ~172.31.255.255
3.C Class address :192.168.0.0~192.168.255.255
2. solve the problem
Regular expressions :
^(10\.\d{
1,3}\.\d{
1,3}\.((0\/([89]|1[0-9]|2\d|3[012]))|(\d{
1,3})))|(172\.(1[6789]|2\\d|3[01])\.\d{
1,3}\.\d{
1,3}(\/(1[6789]|2\d|3[012]))?)|(192\.168\.\d{
1,3}\.\d{
1,3}(\/(1[6789]|2\d|3[012]))?)$
Python give an example
# ABC Intranet address detection
def check_intranet_ip_segment(ip):
''' matching 1.A Class address :10.0.0.0~10.255.255.255 2.B Class address :172.16.0.0~172.31.255.255 3.C Class address :192.168.0.0~192.168.255.255 Match successfully returns True, conversely False '''
result = re.match(r'^(10\.\d{1,3}\.\d{1,3}\.((0\/([89]|1[0-9]|2\d|3[012]))|(\d{1,3})))|(172\.(1[6789]|2\\d|3[01])\.\d{1,3}\.\d{1,3}(\/(1[6789]|2\d|3[012]))?)|(192\.168\.\d{1,3}\.\d{1,3}(\/(1[6789]|2\d|3[012]))?)$', ip)
if result:
return True
else:
return False
版权声明
本文为[GokuCode]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231640214881.html
边栏推荐
- Database dbvisualizer Pro reported file error, resulting in data connection failure
- LVM与磁盘配额
- 04 Lua 运算符
- DDT + Excel for interface test
- ∑GL-透视投影矩阵的推导
- Dlib of face recognition framework
- 5分钟NLP:Text-To-Text Transfer Transformer (T5)统一的文本到文本任务模型
- Introduction to how to set up LAN
- 伪分布安装spark
- There is a problem with the light switch from 1 to 100
猜你喜欢
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
Zhongang Mining: Fluorite Flotation Process
VMware Workstation cannot connect to the virtual machine. The system cannot find the specified file
Xinwangda: HEV and Bev super fast charging fist products are shipped on a large scale
计组 | 【七 输入/输出系统】知识点与例题
Hypermotion cloud migration helped China Unicom. Qingyun completed the cloud project of a central enterprise and accelerated the cloud process of the group's core business system
100 deep learning cases | day 41 - convolutional neural network (CNN): urbansound 8K audio classification (speech recognition)
力扣-746.使用最小花费爬楼梯
Sail soft segmentation solution: take only one character (required field) of a string
DanceNN:字节自研千亿级规模文件元数据存储系统概述
随机推荐
NVIDIA显卡驱动报错
Solution of garbled code on idea console
磁盘管理与文件系统
True math problems in 1959 college entrance examination
Zhongang Mining: Fluorite Flotation Process
Creation of RAID disk array and RAID5
JMeter setting environment variable supports direct startup by entering JMeter in any terminal directory
Nacos 详解,有点东西
There is a problem with the light switch from 1 to 100
Six scenarios of cloud migration
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
浅谈 NFT项目的价值、破发、收割之争
Qipengyuan horizon credible meta universe social system meets diversified consumption and social needs
Real time operation of vim editor
Camtasia2022软件新增功能介绍
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
最详细的背包问题!!!
On the value, breaking and harvest of NFT project
ByteVCharts可视化图表库,你想要的我都有
详解牛客----手套