Split with token info

Posted by boomhauer on Stack Overflow See other posts from Stack Overflow or by boomhauer
Published on 2012-11-14T16:54:29Z Indexed on 2012/11/14 17:00 UTC
Read the original article Hit count: 280

Filed under:
|
|
|

I would like to split a string using multiple chars to split upon. For example, consider spin text format:

This is a {long|ugly|example} string 

I would want to parse this string and split it on the "{", "|", and "}" chars

myString.Split('|','{','}')

Now I have tokens to play with, but what I would like is to retain the info about which char was used to split each piece of the array that is returned.

Any existing code that can do something like this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about string