Line break with line C # .net 1.1.4322

How to split line by line in C # .net 1.1.4322?

Example line:

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

necessary:

Key|Value
Key|Value
Key|Value
  • I cannot use RegEx.Split because the delimiter is ||| and just get each character separately.

  • I cannot use String.Split () overloading since its not in .net 1.1

An example of a decision:

using System.Text.RegularExpressions;

String[] values = Regex.Split(stringToSplit,"\\|\\|\\|");
+3
source share
4 answers

How about using @ "\\\\\ \" in your Regex.Split call? It does | literal characters.

+4
source

One way is to replace and split:

string[] keyvalues = "key|value|||key|value".replace("|||", "~").split('~');
+3
source

here is an example:

System.Collections.Hashtable table;
string[] items = somestring.split("|||");
foreach(string item in items)
{
   string[] keyvalue = item.split("|");
   table.add(keyvalue[0],keyvalue[1]);
}
0
source
string input = "Hi#*#Hello#*#i#*#Hate#*#My#*#......" ;
string[] delim = new string[] { "#*#" };
string[] results = input.split(delim , StringSplitOptions.None); 
0
source

Source: https://habr.com/ru/post/1731932/


All Articles