Regular Expression

package regular;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularExpress {	
	 private static Pattern illegal_database_field =Pattern.compile("[(\\W+) && [^-+#]]");	 
	 public static boolean checkIllegalField(String fieldName) throws Exception{
		 Matcher matcher = illegal_database_field.matcher(fieldName);
		 while(matcher.find()){
			 System.out.println(matcher.group(0));
			return true;
		 }
		 
		 return false;
	 }
	 
	 public static void main(String[] args) throws Exception{
		 String fieldName = "ö12345fsdfasfda";
		 RegularExpress regularExpress = new RegularExpress();
		 System.out.println(regularExpress.checkIllegalField(fieldName));
	 }
}

你可能感兴趣的:(Regular Expression)