dcsimg
Need to search a string inside a String variable
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, September 26, 2001 08:49 AM

Hi,
I need to find whether a string is available in a String of varying length.
i.e., i want to know string "access" is available in a String variable( may have values like "microsoft access 2000 bla bla bla .." or "bla bla access microsoft").
so, i dont know the starting point of the word 'access' in the String variable.
Pls help me in doing this.

Thanks in advance,

Rao

Re: Need to search a string inside a String variable

Posted By:   Jeff_Hubbach  
Posted On:   Wednesday, September 26, 2001 09:04 AM

Check out the Java API for the String class. It lists all available methods in that class.



Here's an example code snippet:


String foo = "the dog is blue";
if(foo.indexOf("dog") != -1)
System.out.println("dog is in the string at index "+foo.indexOf("dog"));
else
System.out.println("dog isn't in the string");
About | Sitemap | Contact