Results 1 to 5 of 5

Thread: Split up a string?

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Split up a string?

    I want to tokenise a string using shell delimiters...

    |, >, <, >>, <<

    I can do that fine, except when the string is like:

    command1>command2

    (i.e - no spaces between commands and tokens)

    Any ideas?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Just do what you would do to split the string normally, except when you find a delimeter, split at that point, but make the next token equal the delimeter.
    Code:
    command1>command2
    tokenizes to
    command1
    >
    command2
    Z.

  3. #3

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    You're a thinker.

    Cheers,
    RJ
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    It becomes a pain in the arse to need to tokenize a string, but need to preserve sections of the string that contain delimeters =).

    Z.

  5. #5

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Most of the relevant function is done for me, just gotta modify. My brain is fried this last few weeks. Had too much on, and I've fizzled out...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

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