1. 程式人生 > >字串中判斷只有英文字母,判斷是否有忽略大小寫相同的字串

字串中判斷只有英文字母,判斷是否有忽略大小寫相同的字串

判斷只有英文字母

public static boolean isEnglish(String charaString) {

return charaString.matches("^[a-zA-Z]*");

}

判斷只有英文字母的字串中,有忽略大小寫的相同的字串

String key="list123TeXthaoge";

String tag="text";

Pattern p = Pattern.compile(tag,Pattern.CASE_INSENSITIVE);
Matcher m=p.matcher(key);
if (m.find()) {
int start=m.start();
int end=m.end();
}