Get the App
SLTechnology News&Howtos  ›  Development  › 

How does JavaScript verify that it is an IP address without port number

Shulou Source: shulou.com Published: 2022-06-01 02:56:22 09月22日 Update

This article mainly introduces how JavaScript checks whether it is an IP address without a port number. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

Verify that it is an IP address without a port number

Verification rules:

IP format is xxx.xxx, and the value range of each item is 0-255.

Numbers other than 0 cannot begin with 0, such as 02.

function isIP(str) {

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

JavaScript is a literal scripting language, its interpreter is called JavaScript engine, is part of the browser, JavaScript is widely used in client-side scripting language, first used in HTML web pages, used to add dynamic features to HTML web pages.

Thank you for reading this article carefully. I hope that the article "How to verify whether JavaScript is an IP address without port number" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Tags: Article slogan address number web page script language value interest function dynamic at the same time customer beginning engine is in more friends format browser Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology Shulou Information MariaDB OPPO Reno