I thought it was gonna be easy comparing user input to existing names in my database(List). To my surprise, there was no matches() pattern available for the String class in Blackberry JDE. I this article here but there are just too many things to look at. I wish they could explain it more in a straightforward manner and not just present a chunk of code to the reader. I'm trying to find help in the blackberryforums site and I hope that I get good luck.
*UPDATE
Finally after a while I was able to make a utility class for this problem. It's not an official regex search so it's not really that powerful but it does the job somehow.
public final class StringUtils {
private StringUtils() { }
public static boolean caseInsensitiveStartsWith(String str1, String str2){
return str1.toUpperCase().startsWith( str2.toUpperCase() );
}
public static boolean caseInsensitiveEndsWith(String str1, String str2){
return str1.toUpperCase().endsWith( str2.toUpperCase() );
}
public static boolean caseInsensitiveIndexOf(String str1, String str2){
return str1.toUpperCase().indexOf( str2.toUpperCase() ) > 0;
}
}
You can use this both for J2SE, J2EE and J2ME. But I haven't optimized this for J2ME. In my case, using this in every contact's telephone number is gonna be making a lot of instantiating and garbage collecting for strings. I hope it's not much of an issue for now...
Finally, it's not a very good thing to claim that the idea is 100% yours. I got the idea from here... Thanks a lot to the author of that code. :)