Dim s As String="甘肃省兰州市安宁区马家镇银滩路街道" Dim l() As String = {"省","市","区","县","乡","镇","村","街道"} Dim li As new List(of String) For i As Integer = 0 To l.Length - 1 If s.contains(l(i)) Then li.Add(l(i)) Next If li.Count = 0 Then Return Nothing Dim strRegex As String = "^" For Each ss As String In li strRegex += "(?<" & ss & ">\w+)" & ss & "+" Next Dim r As New System.Text.RegularExpressions.Regex(strRegex.TrimEnd("+")) For Each ss As String In li Output.show(r.Match(s).Result("${" & ss & "}") & ss) Next
|