|
-
November 23rd, 2004, 10:36 PM
#1
Tokenizing a string with HEX characters
I am trying to tokenize a string that contains non-displayable characters i.e. HEX. How to split a string based on some HEX characters. e.g.
Here represents any HEX character which I want to to set as part of Token along with some string as a Token. can be any HEX character but I just want to split on some of them e.g. in the following sample string I want to split at TEST2
Code:
"StartTEST1TEST2TEST3TEST2TEST4TEST5TEST6TEST2TEST7TEST812END"
based on my Tokens the output should look as below:
Code:
StartTEST1
TEST3
TEST4TEST5TEST6
TEST7TEST812END
Any idea how to do this. Any help is appreciated.
Thanks
-
November 24th, 2004, 05:44 PM
#2
Re: Tokenizing a string with HEX characters
try it using the class StringTokenizer
-
November 24th, 2004, 07:38 PM
#3
Re: Tokenizing a string with HEX characters
The StringTokenizer class is deprecated. The canonical way of splitting strings is to use String.split(...) which uses a regular expression to break the string into an array of substrings.
The Pattern class documents how to develop a regular expression, and shows how hex values can be used.
The greatest obstacle to discovery is not ignorance, but the illusion of knowledge...
D. Boorstin
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|