Java tutorial
//package com.java2s; public class Main { /** * Return true if substring s is in p and isn't all in upper case. This is used to check the case of SYSTEM, PUBLIC, * DTD and EN. * @param s substring * @param p full string * @param len how many chars to check in p * @return true if substring s is in p and isn't all in upper case */ public static boolean findBadSubString(String s, String p, int len) { int n = s.length(); int i = 0; String ps; while (n < len) { ps = p.substring(i, i + n); if (s.equalsIgnoreCase(ps)) { return (!s.equals(ps)); } ++i; --len; } return false; } }