Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String tokenizer

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
i'm trying to tokenizer a date within a text
example if a text contain

"today's date is 01-22-1998 tommorrow's date is 01-23-1998"


i want to pull out the date as tokens
so i want the tokens to be
01-22-1998
01-23-1998

plz help thx
 
I believe, right direction is to use regular expressions.

Ion Filipski
1c.bmp
 
indeed... I think you'll have to run a loop through the string and use the match function....
Code:
for(st = new StringTokenizer(string," "); st.hasNextToken();)
{
   String current = st.nextToken();
   if(current.match("//d//d-//d//d-//d//d//d//d")
   {
Code:
      //do stuff
Code:
   }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top