I have string like this
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 "
with really long space
how can I divide each sentence into a different string like this
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"
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]);
Try using this code
How about like this? Split by 2 spaces or a tab.
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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.