Task

Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified.



Example

Hey you, Bub!    would be shown reversed as:    Bub! you, Hey 



Tokens are any non-space characters separated by spaces (formally, white-space);   the visible punctuation form part of the word within which it is located and should not be modified.

You may assume that there are no significant non-visible characters in the input.   Multiple or superfluous spaces may be compressed into a single space.

Some strings have no tokens, so an empty string   (or one just containing spaces)   would be the result.

Display the strings in order   (1st, 2nd, 3rd, ···),   and one string per line.

(You can consider the ten strings as ten lines, and the tokens as words.)



Input data
             (ten lines within the box)
 line
     ╔════════════════════════════════════════╗
   1 ║  ---------- Ice and Fire ------------  ║
   2 ║                                        ║  ◄─── a blank line here.
   3 ║  fire, in end will world the say Some  ║
   4 ║  ice. in say Some                      ║
   5 ║  desire of tasted I've what From       ║
   6 ║  fire. favor who those with hold I     ║
   7 ║                                        ║  ◄─── a blank line here.
   8 ║  ... elided paragraph last ...         ║
   9 ║                                        ║  ◄─── a blank line here.
  10 ║  Frost Robert -----------------------  ║
     ╚════════════════════════════════════════╝

Cf.
 Phrase reversals


Public Sub Main()
Dim sString As New String[10]                                     'Array for the input text
Dim sLine As New String[]                                         'Array of each word in a line
Dim siCount0, siCount1 As Short                                   'Counters
Dim sOutput, sReverse, sTemp As String                            'Strings
 
sString[0] = "---------- Ice And Fire ------------"               'Input text
sString[1] = "                                    "
sString[2] = "fire, in end will world the say Some"
sString[3] = "ice. in say Some                    "
sString[4] = "desire of tasted I've what From     "
sString[5] = "fire. favor who those with hold I   " 
sString[6] = "                                    "
sString[7] = "... elided paragraph last ...       "
sString[8] = "                                    "
sString[9] = "Frost Robert -----------------------"
 
For siCount0 = 0 To 9                                             'To work through each line of input text
  If Trim(sString[siCount0]) = "" Then sString[siCount0] = " "    'If the line is all spaces then make it 1 space
 
  For Each sTemp In Split(Trim(sString[siCount0]), " ")           'Split the trimmed line by spaces
    sLine.Add(sTemp)                                              'Add each word to the sLine array
  Next
 
  For siCount1 = sLine.max DownTo 0                               'Loop from the last in the sLine array to 0
    sReverse &= sLine[siCount1] & " "                             'Fill sReverse with words reversed, adding a space
  Next
 
  sOutput &= Trim(sReverse) & gb.NewLine                          'Add the reversed words to sOutput and add a newline
  sReverse = ""                                                   'Clear sReverse
  sLine.Clear                                                     'Clear sLine array
Next
 
Print sOutput                                                     'Print the output
 
End