• Post Reply Bookmark Topic Watch Topic
  • New Topic

Case Insensative search  RSS feed

 
john klucas
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i hope some one will help me out here.
i have a piece of code which basically searches whatever the user wants to search for. I have a TextArea which displays the o/p and a text field where users inputs whatever he wants to search for within that text area. But right now i am able to search only for one particular word. If user inputs a new word in place of the previous word it doesn't find that word or even if it finds it start searching from the index of the last word searched. i want the search function, to start searching for a word again from the start index.
Also how can i have case insensative search?
here is my code.
private void doFind()
{
String temp4 = "";
temp4 = ivjTextField1.getText();
String s3 = ivjTextArea1.getText();
int total = s3.length();
if(isfound ==false)
{
int ix = s3.indexOf(temp4);
if(ix >= 0)
{
lastindex = ix+temp4.length();
ivjTextArea1.select(ix, lastindex);
isfound = true;
}
}
else
{
int ix2 = s3.indexOf(temp4, lastindex+1);
if(ix2>=0)
{
lastindex = ix2+temp4.length();
ivjTextArea1.select(ix2, lastindex);
}
temp4 = null;
}
}
can any one help me out. Thanks in advance!
 
Geoff Griffiths
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using the "equalsIgnoreCase(String anotherString) " method of String. or possibly converting both strings to lowercase.
will have to think about you other probs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!