forked from mindspore-Ecosystem/mindspore
!43124 Fix ip regex
Merge pull request !43124 from ZPaC/optimize-ip-regex
This commit is contained in:
commit
c4f2e86de1
|
@ -38,10 +38,8 @@ std::uniform_int_distribution<> CommUtil::dis2 = std::uniform_int_distribution<>
|
|||
|
||||
bool CommUtil::CheckIpWithRegex(const std::string &ip) {
|
||||
std::regex pattern(
|
||||
"(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])"
|
||||
"[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
|
||||
"[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
|
||||
"[.](25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])");
|
||||
"(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.)"
|
||||
"{3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])");
|
||||
std::smatch res;
|
||||
if (regex_match(ip, res, pattern)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue