How do I see if a substring exists inside another string in Java 1.4?
Use a regular expression and mark it as case insensitive:
if (myStr.matches("(?i).*template.*")) {
// whatever
}
The (?i) turns on case insensitivity and the .* at each end of the search term match any surrounding characters (since String.matches works on the entire string).
String.indexOf(String)
For a case insensitive search, to toUpperCase or toLowerCase on both the original string and the substring before the indexOf
String full = "my template string";
String sub = "Template";
boolean fullContainsSub = full.toUpperCase().indexOf(sub.toUpperCase()) != -1;
You can use indexOf() and toLowerCase() to do case-insensitive tests for substrings.
String string = "testword";
boolean containsTemplate = (string.toLowerCase().indexOf("template") >= 0);