Reverse words
Transformed in your browser · nothing is uploaded
Puts the words in the opposite order while every word stays spelled the way it was: "one two three" becomes "three two one". Reversing the characters instead, which gives "eerht owt eno", is the second option, and reversing the order of whole lines is the third.
How to use the reverse words
The text is split into words and the gaps between them, and the whole sequence is turned round. Gaps included. So the spacing is preserved but mirrored: one two three, with a double space after the first word, comes back as three two one, with the double space now before the last. Nothing is normalised on the way through, which is why carefully spaced text can look odd afterwards. Punctuation is part of whatever word it is attached to, so hello, world becomes world hello, with the comma still trailing.
A line break counts as a gap too, so a multi-line block is reversed as one long sequence rather than line by line: the last word of the last line ends up first, and the breaks land in mirrored positions. Reverse line order is the option that keeps each line intact. If what you want is each word spelled backwards but in its original position, that is two passes: reverse the characters, then reverse the word order, and one two comes back as eno owt. Right-to-left scripts are the awkward case: the tokens really are reordered, but the browser lays out Arabic and Hebrew by its own rules, so the result on screen may not look reversed at all.
Questions
Word order keeps every word readable. Character reversal spells the lot backwards; one two three becomes eerht owt eno.
The gaps are kept but mirrored, so a double space after the first word comes back before the last. Nothing is collapsed.
It treats the block as one sequence, because a line break is whitespace, so the last line ends up first. Use reverse line order to keep lines intact.
Yes. "hello, world" becomes "world hello,"; the comma is part of that token.
Not in one pass. Reverse the characters, then reverse the word order, and you are there.
Reversing word order never touches them. Reversing characters can: a flag is two code points, and swapping them gives a different flag or none at all.
The words are reordered, but right-to-left layout is the browser’s job, so the result may not look reversed on screen.