If you know that there's going to be a delimiter ("#" in the example), then you could use StringTokenizer:
StringTokenizer stoken = new StringTokenizer(str);
while (stoken.hasMoreTokens())
{
String stInner = st.nextToken();
if ("H3".equals(stInner))
{
// Do whatever here
}
}
I don't know if that fits your needs or how it compares to other ways of doing it in terms of efficiency, etc.
-David
---------------------------------------
David Deriso
Software Engineer - Employease, Inc.
dderiso@employease.com
404-949-8842
---------------------------------------
-----Original Message-----
From: wsteele3@csc.com [mailto:wsteele3@csc.com]
Sent: Friday, October 05, 2001 7:56 AM
To: ajug-members@www.ajug.org
Subject: help with my String
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