C# 剖析 地址 regex
string zipCode = "", city = "", district = "", town = "", lin = "", road = "", sec = "", len = "", non = "", no = "", floor = "", at = "";
var pattern = @"(?<zipcode>(^\d{5}|^\d{3})?)(?<city>\D{2}[縣市])?(?<district>\D+[鄉鎮市區])?(?<town>\D+[村里])?(?<lin>.+[鄰])?(?<road>\D+[路街大道])?(?<sec>.+[段])?(?<len>.+[巷])?(?<non>.+[弄])?(?<no>.+[號])?(?<floor>.+[樓Ff])?(?<at>[之-].+)?";
Match match = Regex.Match(addr, pattern);
zipCode = match.Groups["zipcode"].ToString();
city = match.Groups["city"].ToString();
district = match.Groups["district"].ToString();
town = match.Groups["town"].ToString();
lin = match.Groups["lin"].ToString();
road = match.Groups["road"].ToString();
sec = match.Groups["sec"].ToString();
len = match.Groups["len"].ToString();
non = match.Groups["non"].ToString();
no = match.Groups["no"].ToString();
floor = match.Groups["floor"].ToString();
at = match.Groups["at"].ToString();