[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with my String
Use the indexOf(String) method on the String class:
public int indexOf(String str)
Returns the index within this string of the first occurrence of the
specified substring. The integer returned is the smallest value k such that:
this.startsWith(str, k)
is true.
Parameters:
str - any string.
Returns:
if the string argument occurs as a substring within this object, then the
index of the first character of the first such substring is returned; if it
does not occur as a substring, -1 is returned.
Throws:
NullPointerException - if str is null.
enjoy,
Alain
At 07:56 AM 10/5/2001 -0400, wsteele3@csc.com wrote:
>I'm having a bit of a brain hiccup. Does anybody know the easiest way of
>checking a string value to see if it includes a certain pair of characters.
>
>ie.
>
>Sting str = "H1#H2#H3#H4#H5#";
>//I want to check to see if the values, "H3" can be found within this
>string.
>
>I didn't see a method for such an operation in the String class. Any ideas
>on an quick way to do this?
>
>Thanks in advance.
>
>Wade Steele