
javascript正则表达式验证ip地址的端口合法性
if (!(/^[1-9]\d*$/.test(port) && 1 <p>提示:</p><p>您的端口不符合范围:0-65535</p><p>下面看下JavaScript(Js)正则表达式验证IP+端口号,代码如下:</p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill13529" title="KeystoneJS 无头 CMS,带有 GraphQL API 和 React 管理界面"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20dbae7c507.jpg" alt="KeystoneJS 无头 CMS,带有 GraphQL API 和 React 管理界面" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill13529" title="KeystoneJS 无头 CMS,带有 GraphQL API 和 React 管理界面" class="overflowclass">KeystoneJS 无头 CMS,带有 GraphQL API 和 React 管理界面</a>
<p class="overflowclass">KeystoneJS 是一个功能强大的开源无头 CMS,适用于 Node.js,它根据您的模式定义自动生成 GraphQL API 和基于 React 的管理界面。由 Thinkmill 构建,支持 PostgreSQL 和 SQLite、自定义访问控制、钩子、虚拟字段和基于文档的富文本编辑。</p>
</div>
<a rel="nofollow" href="/xiazai/skill13529" title="KeystoneJS 无头 CMS,带有 GraphQL API 和 React 管理界面" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div><pre class="brush:js;toolbar:false">var ip="192.168.2.1:8080"
var pattIp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/;
if(pattIp.test(ip)==false)
{
return false;
}
推荐教程:js教程










