Splitting on a Unique Character

I want to build a comma separated list so that I can split on the comma later to get an array of the values. However, the values may have comma's in them. In fact, they may have any normal keyboard character in them (they are supplied from a user). What is a good strategy for determining a character you are sure will not collide with the values?

In case this matters in a language dependent way, I am building the "some character" separated list in C# and sending it to a browser to be split in javascript.


你可以用空字符分割它,并用双空字符来终止你的列表。


If JavaScript is consuming the list, why not send it in the form of a JavaScript array? It already has an established and reliable method for representing a list and escaping characters.

["Value 1", "Value 2", "Escaped "Quotes"", "Escaped  Backslash"]

I always use | but if you still think that it can contain it, you can use combinations like @|@. For example:

"string one@|@string two@|@...@|@last string"
链接地址: http://www.djcxy.com/p/50092.html

上一篇: “执行并更新”#=>'标记'用于VIM

下一篇: 分裂一个独特的人物