How to Break a string into segments containing only text of the string ?
Hi,
I need to break a string with special characters into segments containing only text of the string , not the special chars like ",", " # ", " ","$ " etc.. and then I need to compare the string with database string.
Ex: if string is: " #123, EPIP Phase, White#Field "
it has to be broken into:
Segment 1: 123
Segment 2: EPIP Phase
Segment 3: WhiteField
Can u pls help me with this ?
Thanks,
Sanlearns
[464 byte] By [
sanlearnsa] at [2007-10-2 19:32:19]

Hi,
Try using StringTokenizer Class.
Eg,
StringTokenizer strT = new StringTokenizer("#123, EPIP Phase, white#Field ", ",");
while(strT.hasMoreTokens())
{
System.out.println(strT.nextToken());
}
this gives the output as,
#123
EPIP Phase
white#Field
You can further do the String manipulations to remove those #.
The second parameter in the StringTokenizer class is the delimiter that is to be used to break the string.
Hope this is useful to you.
Regards,
Prasanna