当前位置:网站首页>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
边栏推荐
- Dlib of face recognition framework
- Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
- 05 Lua 控制结构
- 浅谈 NFT项目的价值、破发、收割之争
- G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
- 【Pygame小游戏】10年前风靡全球的手游《愤怒的小鸟》,是如何霸榜的?经典回归......
- G008-HWY-CC-ESTOR-04 华为 Dorado V6 存储仿真器配置
- 05 Lua control structure
- The most detailed Backpack issues!!!
- Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
猜你喜欢

You need to know about cloud disaster recovery

How to build tiktok user trust and drive fan growth

G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration

Sail soft segmentation solution: take only one character (required field) of a string

Set cell filling and ranking method according to the size of the value in the soft report

Pytorch: the pit between train mode and eval mode

ACL 2022 | DialogVED:用于对话回复生成的预训练隐变量编码-解码模型

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

How magical is the unsafe class used by all major frameworks?

Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
随机推荐
◰GL-阴影贴图核心步骤
漫画:什么是IaaS、PaaS、SaaS?
LVM与磁盘配额
loggie 源码分析 source file 模块主干分析
Detailed explanation of UWA pipeline function | visual configuration automatic test
关于局域网如何组建介绍
Custom implementation of Baidu image recognition (instead of aipocr)
File upload and download of robot framework
Pseudo Distributed installation spark
Install MySQL on MAC
Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
∑GL-透视投影矩阵的推导
最詳細的背包問題!!!
English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
正则过滤内网地址和网段
vim编辑器的实时操作
Database dbvisualizer Pro reported file error, resulting in data connection failure
Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
Pytorch: the pit between train mode and eval mode