当前位置:网站首页>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
边栏推荐
- Download and install mongodb
- Six scenarios of cloud migration
- Cartoon: what are IAAs, PAAS, SaaS?
- Query the data from 2013 to 2021, and only query the data from 2020. The solution to this problem is carried out
- 文件系统读写性能测试实战
- NVIDIA graphics card driver error
- Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
- Day 9 static abstract class interface
- 安装及管理程序
- True math problems in 1959 college entrance examination
猜你喜欢
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
You need to know about cloud disaster recovery
Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
深度学习100例 | 第41天-卷积神经网络(CNN):UrbanSound8K音频分类(语音识别)
PyTorch:train模式与eval模式的那些坑
Questions about disaster recovery? Click here
各大框架都在使用的Unsafe类,到底有多神奇?
扫码登录的原理你真的了解吗?
ByteVCharts可视化图表库,你想要的我都有
Selenium IDE and XPath installation of chrome plug-in
随机推荐
磁盘管理与文件系统
The most detailed Backpack issues!!!
The most detailed knapsack problem!!!
Camtasia2022软件新增功能介绍
最詳細的背包問題!!!
PHP 零基础入门笔记(13):数组相关函数
How to quickly batch create text documents?
文件操作详解(2)
Force buckle - 198 raid homes and plunder houses
OMNeT学习之新建工程
JSP learning 2
JMeter setting environment variable supports direct startup by entering JMeter in any terminal directory
Install MySQL on MAC
JSP learning 1
Cartoon: what are IAAs, PAAS, SaaS?
JSP learning 3
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
DDT + Excel for interface test
Gartner 發布新興技術研究:深入洞悉元宇宙
About background image gradient()!