• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

keyword search question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Lookout! Runaway whale! Hide behind this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic