delphi中判断IP地址输入的合法性

function GetSubStrCount(sSubStr, sParentStr: string): integer;
begin
  Result := 0;
  while Pos(UpperCase(sSubStr), UpperCase(sParentStr)) <> 0 do
    begin
      sParentStr := Copy(sParentStr, Pos(sSubStr, sParentStr) + 1, Length(sParentStr)); 
      Result := Result + 1;
    end;

end;

function IsIp(ip:string):boolean;
begin
  if (GetSubStrCount('.', IP) = 3) and (Longword(inet_addr(PAnsiChar(AnsiString(IP)))) <> INADDR_NONE) then
    Result := True
  else
    Result := False;
end;
上一篇:python如何大写字符串中的某些字符


下一篇:.NET 6 Preview 6 正式发布: 关注网络开发