当前位置:网站首页>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
边栏推荐
- Redis "8" implements distributed current limiting and delay queues
- What does cloud disaster tolerance mean? What is the difference between cloud disaster tolerance and traditional disaster tolerance?
- Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
- Public variables of robotframework
- Report FCRA test question set and answers (11 wrong questions)
- How does flash cache data in memory?
- Qipengyuan horizon credible meta universe social system meets diversified consumption and social needs
- 力扣-198.打家劫舍
- 浅谈 NFT项目的价值、破发、收割之争
- Pseudo Distributed installation spark
猜你喜欢

Force buckle-746 Climb stairs with minimum cost
欣旺达:HEV和BEV超快充拳头产品大规模出货

MySQL master-slave replication

深度学习100例 | 第41天-卷积神经网络(CNN):UrbanSound8K音频分类(语音识别)

Creation of RAID disk array and RAID5

Install MySQL on MAC

Sail soft calls the method of dynamic parameter transfer and sets parameters in the title

Gartner 發布新興技術研究:深入洞悉元宇宙

Best practice of cloud migration in education industry: Haiyun Jiexun uses hypermotion cloud migration products to implement progressive migration for a university in Beijing, with a success rate of 1

100 deep learning cases | day 41 - convolutional neural network (CNN): urbansound 8K audio classification (speech recognition)
随机推荐
Esxi encapsulated network card driver
◰GL-着色器处理程序封装
On the security of key passing and digital signature
磁盘管理与文件系统
力扣-746.使用最小花费爬楼梯
Gartner 發布新興技術研究:深入洞悉元宇宙
Nacos detailed explanation, something
G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
Summary according to classification in sail software
OMNeT学习之新建工程
阿里研发三面,面试官一套组合拳让我当场懵逼
Findstr is not an internal or external command workaround
力扣-198.打家劫舍
最详细的背包问题!!!
Nacos 详解,有点东西
Set cell filling and ranking method according to the size of the value in the soft report
Use if else to judge in sail software - use the title condition to judge
The first line and the last two lines are frozen when paging
Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
Use case labeling mechanism of robot framework