• Post Reply Bookmark Topic Watch Topic
  • New Topic

checking two strings in java  RSS feed

 
t sathya narayana
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want get a specific document from data set if a given string matches in that document.

If given string is 'what is java' and,

doc1='... what is full form of java ...'

doc2='... is java what ...'

doc3='... what is java ...'

then the output should contains doc1, and doc3.

I'm trying like this.




please correct it. or give me other solution to do this. I'm getting wrong output containing doc1, doc2 and doc3.
But I want only the exact match. Here each document is containing some paragraphs
Thanks in advance.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why you need to split anything. I would just use the method String.contains("what is java") .
 
t sathya narayana
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote:I don't understand why you need to split anything. I would just use the method String.contains("what is java") .

ok we can write like this. here we can find that exact match. in the above example i am unable to get doc1 (means what is full form of java).
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is your requirement? and example is great, but it really doesn't define things. For example, what if the file had this:

doc3 = 'what is the reason for doing things? in some language, like java, you can do this';

or even this:

doc4 = 'what is the reason for doing things? <snip 27 pages of random text> java, you can do this';

When EXACTLY should you have a match and when shouldn't you?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!