用字符串C#.net 1.1.4322分割字符串(Splitting string with string C# .net 1.1.4322)

编程入门 行业动态 更新时间:2024-10-27 04:34:11
用字符串C#.net 1.1.4322分割字符串(Splitting string with string C# .net 1.1.4322)

如何在C#.net 1.1.4322中用字符串拆分字符串?

字符串示例:

Key|Value|||Key|Value|||Key|Value|||Key|Value

需要:

Key|Value Key|Value Key|Value

我不能使用RegEx.Split,因为分隔符是||| 并且分开获取每个角色。

我不能在.net 1.1中使用String.Split()重载

接受的解决方案示例:

using System.Text.RegularExpressions; String[] values = Regex.Split(stringToSplit,"\\|\\|\\|");

How do I split a string with a string in C# .net 1.1.4322?

String example:

Key|Value|||Key|Value|||Key|Value|||Key|Value

need:

Key|Value Key|Value Key|Value

I cannot use the RegEx.Split because the separating character is the ||| and just get every character separately.

I cannot use the String.Split() overload as its not in .net 1.1

Example of Accepted solution:

using System.Text.RegularExpressions; String[] values = Regex.Split(stringToSplit,"\\|\\|\\|");

最满意答案

怎么样使用@“\ | \ | \ |” 在你的Regex.Split电话? 这使得| 字符文字字符。

What about using @"\|\|\|" in your Regex.Split call? That makes the | characters literal characters.

更多推荐

本文发布于:2023-07-07 09:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1061429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用字   字符串   net   Splitting   string

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!