# How to check if a string is strictly alphanumeric java

How to check if a string is strictly alphanumeric java. I am getting the pattern as below to check but its not working

Pattern p = Pattern.compile("[a-zA-Z0-9]");
return p.matcher(data).find()

How to make it work

It's having a small mistake, check below code for reference:

Pattern p = Pattern.compile("[^a-zA-Z0-9]");
return p.matcher(data).find()