lundi 31 août 2015

Java String - parsing out Strings containing Alpha Characters

In my Code I am trying to seperate out two different types of Strings, IP addresses and DNS addresses. I am having trouble figuring out how to split it. My initial thought is:

String stringIP = "123.345.12.1234";
String stringDNS = "iam.adns234.address.com";

if(!Pattern.matches("^[a-zA-Z0-9.]*$",stringDNS)){
  //I only want to get IP type strings here, so I am trying to separate out anything containing alpha characters. stringDNS should not be allowed into the if statement.
}

Any suggestions would be appreciated!

Aucun commentaire:

Enregistrer un commentaire