CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    10

    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

  2. #2
    Join Date
    Nov 2004
    Posts
    2

    Re: Tokenizing a string with HEX characters

    try it using the class StringTokenizer

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    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
  •  





Click Here to Expand Forum to Full Width

Featured