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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:29:12
Original
2017 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:
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template