Implement a case insensitive contains() method for Java String class
Writing by shivdev on Friday, 12 of November , 2010 at 12:57 pm
One simple solution is to convert both strings to lower case and then use the contains() method.
public boolean containsIgnoreCase(String longString, String shortString) { return (longString.toLowerCase().contains(shortString.toLowerCase())); }
Leave a comment
Category: Java
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-
No Comments
No comments yet.
Leave a comment
You must be logged in to post a comment.