如何修剪数组中的所有空格?
Dim str() As String = {"Tyrannosaurus", _
"Amarga saurus", _
" Mamenchisaurus", _
"Brachios aurus", _
"Deinonychus", _
"Tyr annosaurus", _
" Compsognathus"}
答案 0 :(得分:3)
str = str.Select(Function(s) s.Replace(" ", "")).ToArray()
答案 1 :(得分:1)
Dim reg As New Regex("\s*")
For i = 0 To temp.Length - 1
temp(i) = reg.Replace(temp(i), "")
Next i