In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to verify the correctness of IP and port format through regular expressions. Xiaobian thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Regular expression for 1:ip:
The format is made up of "." Four segmented parts, each with a range of 0-255
The regularity of each paragraph can be divided into several parts: 200-255, 100-1999, 10-99, 0-9.
Regular expression for each part: 2 [0-4]\ d | 25 [0-5]; 1\ d {2}; [1-9]\ d;\ d
So it is connected to\ d | [1-9]\ d | 1\ d {2} | 2 [0-4]\ d | 25 [0-5]
Then the rule of IP is (\ d | [1-9]\ d | 1\ d {2} | 2 [0-4]\ d | 25 [0-5]). (\ d | [1-9]\ d | 1\ d {2} | 2 [0-4]\ d | 25 [0-5])\. (\ d | [1-9]\ d | 1 [0-4] 2} | 25 [0-5])\. (\ d | [1-9]\ d | 1\ d {2} | 2 [0-4]\ d | 25 [0-5])
Expressed in JS as / ^ (\ d | [1-9]\ d | 1\ d {2} | 2 [0-4]\ d | 25 [0-5])\. (\ d | [1-9]\ d | 1\ d {2} | 2 [0-4])\ d | 25 [0-5])\. (\ d | [1-9]\ d | 1\ d {2} | 25 [0-5])\. (\ d | [1-9]\ d | 1\ d {2} | 2 [0-5]). -4]\ d | 25 [0-5]) $/
2: regular expression of the port:
The format is 0-65535.
The same principle can be divided into several parts: 60000-65535 10 000-59999 10-9999 10-99 10-99 10-9
The regularity of each part is: 6 [0-4]\ d {4} | 65 [0-4]\ d {2} | 655 [0-2]\ d | 6553 [0-5]; [1-5]\ d {4}; [1-9]\ d {3}; [1-9]\ d {2}; [1-9]\ d; [0-9]
The results are as follows: ([0-9] | [1-9]\ d {1Magne3} | [1-5]\ d {4} | 6 [0-4]\ d {4} | 65 [0-4]\ d {2} | 6553 [0-5])
Expressed in JS as: / ^ ([0-9] | [1-9]\ d {1pr 3} | [1-5]\ d {4} | 6 [0-4]\ d {4} | 65 [0-4]\ d {2} | 6553 [0-5]) $/
On "how to verify the correctness of IP and port format through regular expressions" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.