strText = "QTP Sreenu Blog"
Output should be "Blog
Sreenu QTP"
Using Split Funtion
arrSubStrings = Split(strText)
For i=UBound(arrSubStrings) To 0 Step -1
strRev = Trim(strRev) & " " & arrSubStrings(i)
Next
MsgBox strRev
Without using any built-in functions
strText = "QTP Sreenu Blog"
Set oRegExp = New RegExp
oRegExp.Pattern = "\d|\D|\s|\S|\t|\w|\W" 'This pattern matches with any character
oRegExp.Global = True
Set oItems = oRegExp.Execute(strText)
iArrayIndex = 0
For i=0 To oItems.Count-1
If oItems(i) <> " " Then
strSub = strSub & oItems(i)
Else
ReDim Preserve arrSubs(iArrayIndex)
arrSubs(iArrayIndex) = strSub
strSub = ""
iArrayIndex = iArrayIndex + 1
End If
Next
ReDim Preserve arrSubs(iArrayIndex)
arrSubs(iArrayIndex) = strSub
For i=UBound(arrSubs) To 0 Step -1
strRev = strRev & " " & arrSubs(i)
Next
MsgBox strRev
Set oRegExp = New RegExp
oRegExp.Pattern = "\d|\D|\s|\S|\t|\w|\W" 'This pattern matches with any character
oRegExp.Global = True
Set oItems = oRegExp.Execute(strText)
iArrayIndex = 0
For i=0 To oItems.Count-1
If oItems(i) <> " " Then
strSub = strSub & oItems(i)
Else
ReDim Preserve arrSubs(iArrayIndex)
arrSubs(iArrayIndex) = strSub
strSub = ""
iArrayIndex = iArrayIndex + 1
End If
Next
ReDim Preserve arrSubs(iArrayIndex)
arrSubs(iArrayIndex) = strSub
For i=UBound(arrSubs) To 0 Step -1
strRev = strRev & " " & arrSubs(i)
Next
MsgBox strRev
No comments:
Post a Comment