Solved

search sting in a word bound in J2SE 1.3

Posted on 2006-10-23
6
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 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