• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

search sting in a word bound in J2SE 1.3

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
lilyyan
Asked:
lilyyan
  • 3
  • 2
1 Solution
 
objectsCommented:
you could add a space to fornt and back and search for that  " electronic "
0
 
lilyyanAuthor Commented:
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
 
objectsCommented:
> 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lilyyanAuthor Commented:
agree, but the word to be searched could be located in the front or back
0
 
shinobunCommented:
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
 
lilyyanAuthor Commented:
then both the kewwords and serach need add space
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now