Ip address Regular Expression matching method, ip address Regular Expression matching

Source: Internet
Author: User

Ip address Regular Expression matching method, ip address Regular Expression matching

A Regular Expression (Regular Expression) is a concept in computer science. Regular Expressions use a single string to describe and match a series of strings that conform to a certain syntax rule. In many text editors, regular expressions are usually used to retrieve and replace texts that match a certain pattern. Many programming languages Support string operations using regular expressions. In many text editors, regular expressions are usually used to retrieve and replace texts that match a certain pattern.

Regular Expression

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

Match 127.0.0.1 | 255.255.255.0 | 192.168.0.1

Unmatched 2.16.5.4.3 | abc. def. ghi. jkl | 255. foo. bar.1

Regular Expression

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

Match 192.168.0.1 | 192.168.0.1/32 | 255.255.0.0/1

Mismatch 010.0.0.0 | 192.168.0.1/33 | 256.0.1.55

Regular Expression

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

Match 97.67.44.20 | 199.154.37.214 | 127.0.0.1

Mismatch 63.125.94.287 | 140.370.a.187 | 94.923.1

Regular Expression
/^ ([01]? \ D? \ D | 2 [0-4] \ d | 25 [0-5]) \.) {3} ([01]? \ D? \ D | 2 [0-4] \ d | 25 [0-5]) \/(\ d {1} | [0-2] {1} \ d {1} | 3 [0-2]) $/

Match 192.168.100.1/24 | 0.0.0.0/0

Does not match 192.168.100.1/33 | 0.0.0.0/90

Regular Expression

\ D + \. \ d +

Match 127.0.0.1 | 255.255.255.0 | 192.168.0.1

Mismatch @ #. 5.4.3 | abc. def. ghi. jkl | 255. foo. bar.1

Regular Expression

^ (\ D | [0-1] \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [0-1] \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [0-1] \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d | [0-1] \ d | 2 [0-4] \ d | 25 [0-5]) $

Match 1.198.0.1 | 100.10.0.1 | 200.200.123.123

Mismatch .. 12.23 | a.23.345 | 400.500.300.300

Regular Expression

^ (\ D {1, 2} | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d {1, 2} | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d {1, 2} | 1 \ d | 2 [0-4] \ d | 25 [0-5]) \. (\ d {1, 2} | 1 \ d | 2 [0-4] \ d | 25 [0-5]) $

Match 0.0.0.0 | 255.255.255.255.02 | 192.168.0.136

Mismatch 256.1.3.4 | 023.44.33.22 | 10.57.98.23.

Regular Expression

^ (Http | https | ftp )\: // (25 [0-5] | 2 [0-4] [0-9] | 1 [0-9] [0-9] | [1-9] [0-9] | [0-9]) \.) {3} (25 [0-5] | 2 [0-4] [0-9] | 1 [0-9] [0-9] | [1-9] [0-9] | [0-9]) | ([a-zA-Z0-9 _ \-\.]) + \. (com | net | org | edu | int | mil | gov | arpa | biz | aero | name | coop | info | pro | museum | uk | me ))((: [a-zA-Z0-9] *)? /? ([A-zA-Z0-9 \-\._\? \, \ '/\ + & % \ $ # \ = ~]) *) $

Match http://www.allkins.com | http: // your desired amount 255 | http://allkins.com/page.asp? Action = 1

Does not match http://test.testing

Regular Expression

^ ([0-2] * [0-9] + [0-9] + )\. ([0-2] * [0-9] + [0-9] + )\. ([0-2] * [0-9] + [0-9] + )\. ([0-2] * [0-9] + [0-9] +) $

Match 113.173.40.255 | 171.132.248.57 | 79.93.28.178

Mismatch 189.57.135 | 14.190.193999 | A. N. D.233

Regular Expression

\ B ([01]? \ D? \ D | 2 [0-4] \ d | 25 [0-5]) \.) {3} ([01]? \ D? \ D | 2 [0-4] \ d | 25 [0-5]) \ B

Matching 217.6.9.89 | 0.0.0.0 | 255.255.255.255

Mismatch 256.0.0.0 | 0978.3.3.3 | 65.4t.54.3

The above section describes the IP address Regular Expression matching method, which is helpful to you!

Articles you may be interested in:
  • Js: Regular Expression for verifying IPv6 addresses
  • Javascript obtains the regular expression in the first slash of The Link file address.
  • Php code for obtaining the physical address of the specified IP address (regular expression)
  • C # Regular Expression Decomposition and conversion of IP address instances (C # Regular Expression Daquan c # regular expression syntax)
  • Python Regular Expression matches IP address instances
  • Javascript uses regular expressions to detect IP addresses
  • Verify IP addresses using Shell Regular Expressions
  • Matching IP addresses using regular expressions in Shell scripts
  • Regular Expressions matching IP addresses and domain names

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.