• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding exact element in String  RSS feed

 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a string strCurrentTableRow which contains xxxxxxxxxCD01xxCD01(A)xxxxxxxxAB01xxxxxxxxxxxAB01(A)xxxxxxxxx where x is any character and the position of AB01 can change anywhere.

Now, I'm using a variable strCurrentRequiredJf which will have either AB01 or AB01(A), which will be dynamic, meaning it can be CD01 or CD01(A) as well based on the stuff selected by the end user.

I have an IF condition in a part of the code which contains many WHILE loops,


in this case, since 'contains' returns true both for AB01 & AB01(A), the code in the loop will execute twice whereas it should have happened just once.

In short, how to find the exact substring in a string.
contains() doesn't work, so does indexOf().

So how to rectify this issue.

Please advise.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed in the indexOf condition and found the result.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!