VB.net 字符串 分割 及 重新倒序组装

    ''' <summary>
    ''' split with ">>>>" , and inverted order
    ''' </summary>
    ''' <param name="groupNamePath"> 123>>>>abc>>>>456 </param>
    ''' <returns> 456 > abc > 123 </returns>
    ''' <remarks></remarks>
    Protected Function transGroupNamePath(ByVal groupNamePath As String) As String
        Dim strResult As String = ""
        Dim strArray As String() = Regex.Split(groupNamePath, ">>>>")

        For i As Integer = strArray.Length - 1 To 0 Step -1
            If Not strArray(i) = "" Then
                If strResult = "" Then
                    strResult = strResult & strArray(i)
                Else
                    strResult = strResult & " > " & strArray(i)
                End If
            End If
        Next
        transGroupNamePath = strResult
    End Function

 

你可能感兴趣的:(VB.NET)