Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to validate an IP address in R?

Description

To validate an IP address in R

Libraries required :

require(MASS)

require(ggplot2)

require(scales)

require(gridExtra)

Process

  Load the IP Address

  Split the IP address with the pattern \\.

  Check for the required criteria of the splitted values

  Verify the output

Sapmle Code

ip1=readline(prompt=”Enter the IP address : “)
strsplit(ip1,’\\.’)
y=0
x=as.integer(unlist(strsplit(ip1,’\\.’)))
if(length(x)==4)
{
for (i in (1:4))
{
if((x[i]>=0)&&(x[i]<256))
{
y=y+1
}
}
if(y==4)
{
cat(“\nValid IP Address”)
}else
{
cat(“Invalid IP Address”)
}
}else
{
cat(“\nInvalid Address”)
}

Screenshots
How to validate an IP address in R
Load the IP Address
Split the IP address with the pattern