16,554
社区成员
发帖
与我相关
我的任务
分享
Dim str As String = "浙江省 山州市 在清有 有一镇上溪有路350号一回上花园东在门往共300米在(312345)"
Dim list = Regex.Match(str, "([^\x00-\xff]|[\x00-\xff]{1,2}){1,24}$").Groups(1).Captures.OfType(Of Capture)().[Select](Function(t) New With { _
Key .value = t.Value, _
Key .count = Encoding.Unicode.GetBytes(t.Value).Where(Function(tt) tt <> 0).Count() _
}).ToList()
str = String.Join("", list.Skip(list.[Select](Function(t, index) If(list.Skip(index).Sum(Function(tt) tt.count) <= 24, index, -1)).First(Function(t) t <> -1)).[Select](Function(t) t.value).ToArray())
Console.WriteLine(str)
Dim s As String = "浙江省 山州市 在清有 有一镇上溪有路350号一回上花园东在门往共300米在(312345)"
Dim part As String = Microsoft.VisualBasic.Right(s, 18)
Dim ary = "浙江省 山州市 在清有 有一镇上溪有路350号一回上花园东在门往共300米在(312345)".Reverse().ToList()
Dim sb As New StringBuilder()
Dim count As Integer = 0
While count < 24
Dim c = ary.First()
If Convert.ToInt32(c) < &Hff Then
count -= 1
End If
count += 2
sb.Append(c)
ary.RemoveAt(0)
End While
Console.WriteLine(String.Join("", sb.ToString().Reverse().ToArray()))