In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
What is a regular expression for an IP address? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
The length of the IP address is 32 bits, divided into 4 segments, each segment with 8 bits, represented by decimal numbers, each segment with a range of 0,255 numbers, with English periods between segments. Separate it. For example, the IP address of a computer is 10.11.44.100.
Analyze the composition characteristics of IP address: 250,255,200-249,0199.
These three situations can be considered separately.
250-255: features: three digits, 100 digits are 2, ten digits are 5, and each bit is 0,5, which can be written as: 25 [0-5] with regular expressions.
200-249: features: three digits, one hundred digits are 2, ten digits are 0,4, and each digit is 09.It can be written as: 2 [0-4]\ d with regular expressions.
0-199: this can be further split to make it easier to write.
0-9: characteristics: one digit, each digit is 09, which can be written as:\ d with regular expression.
10-99: features: two digits, ten digits are 1 to 9, and each bit is 0 to 9, which can be written as: [1-9]\ d with regular expressions.
100-199: features: three digits, 100 digits are 1, ten digits are 09, and each bit is 09. it can be written as: 1\ d {2} with regular expression.
So the regular expression of 0-99 can be written as [1-9]?\ d, then 0-199 can be written as (1\ d {2}) | ([1-9]?\ d), so that the regular expression of 0-99 can be written as (25 [0-5] | 2 [0-4]\ d | (1\ d {2}) | ([1-9]?\ d))
Finally, add a period to the first three paragraphs. You can get it repeatedly using {3}, and do the same match in paragraph 4 to get the regular expression of the IP address:
((?: 25 [0-5] | 2 [0-4]\ d | (1\ d {2}) | ([1-9]?\ d) {3} (?: 25 [0-5] | 2 [0-4]\ d | (1\ d {2}) | ([1-9]?\ d)
To interact with you:
Why does the three-digit match come before the two-digit / one-digit number? Because one of the regular expression rules: the first match has the highest priority.
2. 0.0.0.0 and 255.255.255.255 are legitimate IP addresses. Do you know why?
3. The number 192.169.01.108 is preceded by an extra type of 0, which is not legal here. Why?
4. Why is there at the front?:? What's its use here?
5. If you find an error in this expression, please also leave a message to correct it!
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.