ShipTo/Dept#: 0011125227-
BIENVILLE SURGERY CENTER LLC
SUITE 102
6300 EAST LAKE BLVD
VANCLEAVE, Mississippi 39565
我想拆分上面的文字,只得到 -
BIENVILLE SURGERY CENTER LLC
SUITE 102
分裂后。
答案 0 :(得分:0)
在C#中对吗? 这段代码应该有效:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class MainClass {
public static void Main (string[] args) {
IList<string> names = "ShipTo/Dept#: 0011125227 - BIENVILLE SURGERY CENTER LLC SUITE 102 6300 EAST LAKE BLVD VANCLEAVE, Mississippi 39565".Split('-').Reverse().ToList<string>();
Console.WriteLine(names[0]);
}
}
从上面的代码中,它应该给出结果: Result from the code
更新:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
class MainClass {
public static void Main (string[] args) {
IList<string> names = "ShipTo/Dept#: 0011125227 - BIENVILLE SURGERY CENTER LLC SUITE 1022 asdf 6300 EAST LAKE BLVD VANCLEAVE, Mississippi 39565".Split('-').Reverse().ToList<string>();
string character = Regex.Match(names[0], @"^[^0-9]*").Value.Trim();
string number = new string(names[0].SkipWhile(c=>!char.IsDigit(c)).TakeWhile(c=>char.IsDigit(c)).ToArray());
Console.WriteLine(character+" "+number);
}
}