Solved

search sting in a word bound in J2SE 1.3

Posted on 2006-10-23
6
258 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now