Home > Web Front-end > JS Tutorial > body text

JavaScript uses regular expressions to detect IP addresses_javascript tips

WBOY
Release: 2016-05-16 16:29:12
Original
1924 people have browsed it

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 ".".

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!