File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Keyword search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Keyword search" Watch "Keyword search" New topic
Author

Keyword search

jasmine dyaga
Greenhorn

Joined: Apr 11, 2012
Posts: 8
Hi ,

When i give my item no:8415-00-051-1173 in search bar it displays item details of that particular product.

But i need to get same results when i give without hypens i.e 8415000511173 .

Can anyone guide me to get this result

Thanks,
Jasmine
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

If the format is exactly the same, i.e: nnnn-nn-nnn-nnnn then simply rebuild the string using subString() and concatenation.

WP
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

Please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/javaserver-pages-jsp-jstl/58102-keyword-search.html


luck, db
There are no new questions, but there may be new answers.
jasmine dyaga
Greenhorn

Joined: Apr 11, 2012
Posts: 8
Hi ,

I used substring and conactenation.



But it is displaying the same results.When i give without "-",it is not displaying the results
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

jasmine password wrote:I used substring and conactenation.


No, you didn't. Everything you posted there is a comment, not executable code. (I added the code tags to your post to make it more readable. It would be good if you did that yourself in the future.)
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 507
jasmine password wrote:Hi ,

When i give my item no:8415-00-051-1173 in search bar it displays item details of that particular product.

But i need to get same results when i give without hypens i.e 8415000511173 .

Can anyone guide me to get this result

Thanks,
Jasmine


How do you store item no in database? If it is stored WITH hyphen,

1) If search string is WITHOUT hyphen (eg. 8415000511173) then you need to format your database field, which stores item #, to remove hyphen while comparing in database query. OR if item # has FIXED format of 4-2-3-4 then better way is to format the search string in predefined format and then query database normally.

2) The other case, WITH hyphen is already working.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Keyword search