Home Web Front-end JS Tutorial JavaScript uses regular expressions to detect IP addresses_javascript tips

JavaScript uses regular expressions to detect IP addresses_javascript tips

May 16, 2016 pm 04:29 PM
ip javascript regular expression

Regular expression:

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

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

The red block represents: the first character is 2, the second character is 0 to 4, and the third character is any digit. Indicates 200~249.

The green block represents: the first character is 2, the second character is 5, and the third character is 0 to 5. Indicates 250~255.

The blue block represents: the first character is 0, or 1, or it does not need this character, the second character is any digit, the third character is any digit, it does not need this character. Represents 1~199, and can have leading zeros.

"|" means "or", as long as it meets the meaning of any one of the three pieces.

The "(" and ")" before and after indicate that this is a group

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

{3} means repeat three times. For example, "255.255.255."

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

The meaning of the last group is the same as above, that is, the same test is added after ".".

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP regular expressions: exact matching and exclusion of fuzzy inclusions PHP regular expressions: exact matching and exclusion of fuzzy inclusions Feb 28, 2024 pm 01:03 PM

PHP regular expressions: exact matching and exclusion of fuzzy inclusions

PHP regular expression validation: number format detection PHP regular expression validation: number format detection Mar 21, 2024 am 09:45 AM

PHP regular expression validation: number format detection

How to validate email address in Golang using regular expression? How to validate email address in Golang using regular expression? May 31, 2024 pm 01:04 PM

How to validate email address in Golang using regular expression?

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

Simple JavaScript Tutorial: How to Get HTTP Status Code

How to match timestamps using regular expressions in Go? How to match timestamps using regular expressions in Go? Jun 02, 2024 am 09:00 AM

How to match timestamps using regular expressions in Go?

Is Douyin's IP location real-time positioning? How long does it take for the IP to change when I go out of town? Is Douyin's IP location real-time positioning? How long does it take for the IP to change when I go out of town? Mar 07, 2024 pm 08:20 PM

Is Douyin's IP location real-time positioning? How long does it take for the IP to change when I go out of town?

How to verify password using regular expression in Go? How to verify password using regular expression in Go? Jun 02, 2024 pm 07:31 PM

How to verify password using regular expression in Go?

The national server is stable! Blizzard will authorize the development of World of Warcraft IP, NetEase is the only choice The national server is stable! Blizzard will authorize the development of World of Warcraft IP, NetEase is the only choice Apr 04, 2024 am 09:04 AM

The national server is stable! Blizzard will authorize the development of World of Warcraft IP, NetEase is the only choice

See all articles