This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

keyword search question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I am working on a problem that requires that I find a keyword within a text file. I have tokenized the input and I can easily locate the keyword as an exact token match but if the keyword appears within a token then it is missed.
example:
keyword = mary
File contains "mary had a little lamb". Keyword is found.
File contains "littlemary had a lamb". Keyword is not found.
Can someone please help me solve the problem?
Thanks.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
If your tokens are Strings (as i would expect them to be) you could use the String.indexOf(...) instead of String.equals(...)
/Peter
 
joeF
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joeF,
Welcome to the Java Ranch,
we hope you’ll enjoy visiting as a regular however I want to remind you ONCE AGAIN, your name is not in keeping with our naming policy
here at the ranch. Please change your display name to an appropriate name as shown in the policy.
You can change your profile here.
Thanks again and we hope to see you around the ranch!!
Cindy
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!