我有这个字符串使用C#分割字符串分隔符多
"abc,\u000Bdefgh,\u000Bjh,\u000Bkl"
,我需要拆分C#中的字符串,每次,\u000B
出现应该是一个新词。
我尝试这样做:
string[] newString = myString.Split(",\u000B");
,但它没有工作,我怎么能做到这一点?
我有这个字符串使用C#分割字符串分隔符多
"abc,\u000Bdefgh,\u000Bjh,\u000Bkl"
,我需要拆分C#中的字符串,每次,\u000B
出现应该是一个新词。
我尝试这样做:
string[] newString = myString.Split(",\u000B");
,但它没有工作,我怎么能做到这一点?
更改split命令是:
string[] newString = ip.Split(new[]{",\u000B"}, StringSplitOptions.RemoveEmptyEntries);
或使用,StringSplitOptions.None
如果您想保留空项,而分裂。
string[] newString = myString.Split(new string[] { ",\u000B" }, StringSplitOptions.None);
作品在我的机器
谢谢,但我接受了我得到的第一个答案 – Ovi
上你可以使用短字符转义符号: “\ V”代替。
Short UTF-16 Description
--------------------------------------------------------------------
\' \u0027 allow to enter a ' in a character literal, e.g. '\''
\" \u0022 allow to enter a " in a string literal, e.g. "this is the double quote (\") character"
\\ \u005c allow to enter a \ character in a character or string literal, e.g. '\\' or "this is the backslash (\\) character"
\0 \u0000 allow to enter the character with code 0
\a \u0007 alarm (usually the HW beep)
\b \u0008 back-space
\f \u000c form-feed (next page)
\n \u000a line-feed (next line)
\r \u000d carriage-return (move to the beginning of the line)
\t \u0009 (horizontal-) tab
\v \u000b vertical-tab
这只是一个长度为两个字符的分隔符。它怎么不起作用? – BoltClock
@BoltClock - 可能因为Split没有超载,只需要一个字符串作为参数。 –
我知道,我促使OP说的不仅仅是“它没有工作”。 – BoltClock