This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Case Insensative search  RSS feed

 
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!
 
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.
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!