我有这样的字符串
string asd = "PT. Mitra Adiperkasa Tbk 01.710.880.4-054.000 Wisma 46 Kota BNI Lt. 8 Jl Jend Sudirman Kav 1, Jak Pus "
空间很长
如何将每个句子分成不同的字符串 像这样
string asd1 = "PT. Mitra Adiperkasa Tbk"
string asd2 = "01.710.880.4-054.000"
string asd3 = "Wisma 46 Kota BNI Lt. 8"
string asd4 = "Jl Jend Sudirman Kav 1, Jak Pus"
答案 0 :(得分:3)
string abc = "abc def ghi";
string[]xyz= System.Text.RegularExpressions.Regex.Split(abc, @"\s{2,}");
System.Console.WriteLine(xyz[0]);
System.Console.WriteLine(xyz[1]);
尝试使用此代码
答案 1 :(得分:2)
这样怎么样?拆分2个空格或标签。
static void Main(string[] args)
{
string asd = "PT. Mitra Adiperkasa Tbk 01.710.880.4-054.000 Wisma 46 Kota BNI Lt. 8 Jl Jend Sudirman Kav 1, Jak Pus ";
foreach (string s in asd.Trim().Split(new string[] { " ", " " }, StringSplitOptions.RemoveEmptyEntries))
{
Console.WriteLine(s);
}
Console.ReadKey();
}