mercredi 25 mars 2015

Why I am getting error while using Pattern class to identify string whether its valid or not?


package app;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class ValidIdentifierDemo

{

public static void main(String s[])

{

Pattern p=new Pattern.compile("[a-z A-z][a-z A-Z 0-9]+"); //error here

Matcher m=p.matcher("int");

if(m.find()&&m.group().equals(s[0]))

{

System.out.println("Valid");

}

else

{

System.out.println("InValid");


}

}

}

Aucun commentaire:

Enregistrer un commentaire