Solved

search sting in a word bound in J2SE 1.3

Posted on 2006-10-23
6
273 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

691 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