Solved

search sting in a word bound in J2SE 1.3

Posted on 2006-10-23
6
266 Views
Last Modified: 2010-03-31
Hello,

For some reason, I have to use j2se 1.3.

when i use indexOf() method, for example: there are two strings :

1. Physics of electronic and optoelectronic devices

2. Microelectronics and Nanotechnology

the word i need to find out is electronic, in this case string 1 should be the result, but if using indexOf() method, both strings will be the results.

my question is: is there a way that i can only get "Physics of electronic and optoelectronic devices"? by using j2se1.3

Thank you so much for your reply,

lilyyan
0
Comment
Question by:lilyyan
  • 3
  • 2
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17792912
you could add a space to fornt and back and search for that  " electronic "
0
 

Author Comment

by:lilyyan
ID: 17793031
hi, thanks for your prompt reply. that's a good idea.

the application currently i'm doing is user input some keywords, e.g. electronic acids disease, the progarm will get the tokens of the input string, i.e.
electronic
acids
disease
 then the program will search the token within a certian of a table

if the srting is: "electronic and optoelectronic devices", adding space to fornt and back to "electronic", will still get the result?



0
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 17793045
> if the srting is: "electronic and optoelectronic devices", adding space to fornt and back to "electronic", will still get the result?

no, but adding a leading and trailing space to the string being search will fix that problem.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:lilyyan
ID: 17793087
agree, but the word to be searched could be located in the front or back
0
 
LVL 9

Expert Comment

by:shinobun
ID: 17793218
As objects said, "a leading _and_ trailing space" would do the trick.

So "electronic and optoelectronic devices" would become " electronic and optoelectronic devices " before you search.
0
 

Author Comment

by:lilyyan
ID: 17793232
then both the kewwords and serach need add space
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 213
HTTPSessionBindingListernter not configured in deployment descriptor 2 65
print map entry 34 72
pagenation logic how it is working in my code 1 55
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question