[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: help with my String



Title: RE: help with my String
Oh well...
I think that the indexOf() method is better than my suggestion below.  Of course, as soon as I hit send, someone posts a better idea...<g>
 
-David
-----Original Message-----
From: dderiso@employease.com [mailto:dderiso@employease.com]
Sent: Friday, October 05, 2001 8:32 AM
To: wsteele3@csc.com; ajug-members@www.ajug.org
Subject: RE: help with my String

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