国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - Looking for a set of JS regular rules about IP addresses!
扔個(gè)三星炸死你
扔個(gè)三星炸死你 2017-07-05 10:38:27
0
4
905

For example, if you want to match this

22.22.22.0/16
33.33.33.1/24

How to write such a regular change? Please give me some advice


This seems to work

/((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)\/[0-2][0-4]/
扔個(gè)三星炸死你
扔個(gè)三星炸死你

reply all(4)
洪濤


Given in "Must Know Regular Expressions". It’s easy to make mistakes when you write it yourself

過去多啦不再A夢(mèng)

^((0|1[0-9]{0,2}|2[0-9]{0,1}|20-4|25[0-5]|3-9{0,1}).){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|20-4|25[0-5]|3-9{0,1})(?(/)/([0-9]|1-2|3[0-2])|)$

漂亮男人

new RegExp(/([0-9]{1,3}.{1}){3}[0-9]{1,3}/)

為情所困

You can directly find a regular match for IP on the Internet, but the one on the Internet may not be correct, and it is not easy to verify, so we will write one ourselves.

There is a tool for generating regular expressions from a numerical range. [Tools can be found online]
ip rules
0-255.0-255.0-255.0-255/0-32

0-255

([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]|25 [0-5])

0-255.

([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]|25 [0-5]).

Repeat 3 times

(([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]| 25[0-5]).){3}

Splice again 0-255

(([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]| 25[0-5]).){3}([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0 -4][0-9]|25[0-5])

0-32

([0-9]|[12][0-9]|3[0-2])

All stitched together

(([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]| 25[0-5]).){3}([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0 -4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])

Add first separator

^(([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9] |25[0-5]).){3}([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[ 0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$
or
(?^ |s)(([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9] |25[0-5]).){3}([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[ 0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])(?:s|$)

  • The dividing symbols are replaced according to the actual situation

  • If no separator is added, 33.33.33.1/24 will be matched into 33.33.33.1/2 or 99933.33.33.1/24 will also be matched

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template