[Question]
  [
In chat, we are often fast-typers and don't really look at the [order](https://chat.stackexchange.com/transcript/message/41967809#41967809) of [letters](https://chat.stackexchange.com/transcript/message/41967812#41967812) before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.
Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word `Thansk` turns into `Thanks`). A *word* is a sequence of two or more letters in the English alphabet delimited by **a single** space.
* The string / list of *characters* you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).
* You can take input and provide output through any [standard method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods), in any [programming language](https://codegolf.meta.stackexchange.com/a/2073/59487), while taking note that [these loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden by default.
* The output may have one trailing space and / or one trailing newline.
* The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.
This is code-golf, so the shortest submission (scored in bytes), in each language wins!
### Test cases
Note that the strings are surrounded with quotes for readability.
```
Input -> Output
"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"
```
Or, for test suite convenience, here are the inputs and their corresponding outputs separately:
```
Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
```
```
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs
```
Thanks to [DJMcMayhem](https://codegolf.stackexchange.com/users/31716/djmcmayhem) for the title. This was originally a [CMC](https://chat.stackexchange.com/transcript/message/41967829#41967829).
  
[Answer]
# [V](https://github.com/DJMcMayhem/V), 4 ~~5~~ bytes
```
òeXp
```
[Try it online!](https://tio.run/##HcsxDsIwEETR3qeYq0QCRJEKpYDSikexxbJe2Q6@F1fgYCZC@uX77zG@H95tjCV6rU/3yDsLOmXNfLklpoojr/BmQneRZJY2xczWWAumkvegrl2JfApY4zTLWbmhp9hQ@7EFQv769gM "V – Try It Online")
`||` denotes the cursor
The buffer starts with `|w|ord and more words` and the cursor being on the first character.
Recursively `ò`
go to the `e`nd of a word
`wor|d| and more words`
remove `X` the character to the left of the cursor
`wo|d| and more words`
`p`aste it over the next character
`wod|r| and more words`
Implicit ending `ò`, repeat the same process for other words until the end of the buffer is reached
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ḳœ?@€2K
```
A monadic link taking and returning lists of characters
**[Try it online!](https://tio.run/##y0rNyan8///hjk1HJ9s7PGpaY@T9//9/JbeczIKCzPQ8BZ/UkpLU4iIFx6L80pQ8JQA "Jelly – Try It Online")**
### How?
```
Ḳœ?@€2K - Link: list of characters
Ḳ       - split at spaces
     2  - literal two
    €   - for €ach:
   @    -   with sw@pped arguments:
 œ?     -     nth permutation (the 2nd permutation has the rightmost elements swapped)
      K - join with spaces
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 122 bytes
```
{(({})[((((()()){}){}){}){}])((){[()](<{}>)}{}){{}<>(({}({}))[({}[{}])])(<>)}{}({}<>)<>}<>(({}({}))[({}[{}])]){({}<>)<>}<>
```
[Try it online!](https://tio.run/##dYs9CoAwDIWv4pgMvUHpKdxKhyr@FKWD7RZy9pgIgovhLXnv@6Yrl@rWMx8iBECMEewQEPV5k1ArioAJPHFAtpbYB1PMUo04GqiofwCwHX34oeizi4x7aYOmL62Xuombbw "Brain-Flak – Try It Online")
The worst language for the job :)
~~Readable~~ Slightly more readable version:
```
{
    (({})[((((()()){}){}){}){}])((){[()](<{}>)}{})
    {
        {}
        <>
        (({}({}))[({}[{}])])
        (<>)
    }
    {}
    ({}<>)<>
}<>
(({}({}))[({}[{}])])
{
    ({}<>)
    <>
}<>
```
[Answer]
# [Python 3](https://docs.python.org/3/), 50 bytes
```
print(*(w[:-2]+w[:-3:-1]for w in input().split()))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v6AoM69EQ0ujPNpK1yhWG0QZW@kaxqblFymUK2TmAVFBaYmGpl5xQU4mkNbU/P@/JCOzWAGIkvNTUtPzc9IA "Python 3 – Try It Online")
This answer abuses Python 3's behavior of print: Multiple arguments are printed with a single space between them. Of course, we can't just give it multiple arguments because we don't know how many words will be in the input. So we use the [splat operator](https://stackoverflow.com/q/2322355/3524982). Basically
```
print(*[a,b,c])
```
is exactly the same thing as
```
print(a,b,c)
```
Abusing that makes a full program turn out shorter than a function/lambda where we'd have to use `' '.join` or something similar.
[Answer]
# [Haskell](https://www.haskell.org/), 40 bytes
```
(f=<<).words
f[a,b]=b:a:" "
f(x:r)=x:f r
```
[Try it online!](https://tio.run/##BcGxDoIwEADQna@4NA6QqB/Q0MHFyY1RHA7o1cZaLtcS@HrP995YPj4lDW7Ullzfd9d9laU09MTz9HKTRWvANNQeVjp3WALRL8YMDnirQxU4QQBzT5E5hgwPX6svAjdZtyUb/c2UMBS9zMx/ "Haskell – Try It Online") Usage example: `(f=<<).words $ "abc xyz"` yields `"acb xzy "`.
[Answer]
# [Retina](https://github.com/m-ender/retina), 13 bytes
```
(.)(.)\b
$2$1
```
[Try it online!](https://tio.run/##HcuxCsIwEIDh/Z7ihg66CPoGBRWHTtKl4BKbozk8LyG5ksePQfjG/89krK61w@nYvd4wXIZza3NwWj6wxJ0yVpI10hfmwAU7p@hSEoK7cEq8KU5kRiXjmOPuFexBGK8e1zBOclPasHIwLLVvnlD@9fMH "Retina – Try It Online") Link includes test cases.
[Answer]
# [Matlab](https://www.mathworks.com/products/matlab.html) (R2016b), ~~51~~ 50 bytes
Saved ~~49~~ 50 (!) bytes thanks to @Giuseppe.
```
function s(a),regexprep(a,'(\w)(\w)( |$)','$2$1 ')
```
And my previous answer:
# [Matlab](https://www.mathworks.com/products/matlab.html) (R2016b), 100 bytes
(Just for the fun of it :P)
```
function s(a),a=regexp(a,' ','split');for i=1:length(a),fprintf('%s ',a{i}([1:end-2 end end-1])),end
```
Explanation:
```
function s(a) % Defining as a function...
a=regexp(a,' ','split'); % Splits the input string at the spaces
for i=1:length(a) % Loops through each word
    fprintf('%s ',a{i}([1:end-2 end end-1])) % And prints everything with the last two characters swapped.
end
```
[Answer]
# C, ~~62~~ ~~58~~ 54 bytes
*Thanks to @Dennis for saving ~~four~~ eight bytes!*
```
f(char*s){s[1]>32||(*s^=s[-1]^=*s^=s[-1]);*++s&&f(s);}
```
[Try it online!](https://tio.run/##XZBBa8MwDIXv/hWCQRun7Vg7tkuWQmEbO/Q0ehlZCsFRYjPXCZFDDm1@e2a3I4EJHcR7Tx9CYlUKMQxFIGTWhMTPlKzT7ePmcglCOsaUrNbpMR5HHoWLBc1mRUA86oc7ZYRuc4QXsrmq7uWWMWUsnDJlAs7ODFx5MpBtks3TcxpdpU4qjRAUJVoKnLUE5y3BQwzn18ht15cHaog9QqPxcR5NZgFeSbQ7DuIY5t9mzkd3gviacvAwEfpxKv6x6/Z23Z/Us344yMzQD/uqWmygQy0qPLGDVASuMwNZXWtk71rVtSoN7NFapAZ2TdXmhtkPhOo1dx/Z7fWbwRI6JS1Q59bcE/U1/fkL)
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 60 bytes
```
[A,B]+[B,A].
[A,B,32|U]+[B,A,32|Y]:-U+Y,!.
[A|U]+[A|Y]:-U+Y.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/P9pRxylWO9pJxzFWjwvE0TE2qgmFiICYkbFWuqHakTqKIFmwhCNMTO///8SS/Nz45PyU1GIN9ZLU4hKF4pKizLx0dR1noJgmmNSO0EFS5ZIKonUiNPUA "Prolog (SWI) – Try It Online")
## Explanation
First we define the base case:
```
p([A,B],[B,A]).
```
This means that the last two letters will always be swapped.
Then we define what happens if we are right next to a space:
```
p([A,B,32|U],[B,A,32|Y]):-p(U,Y),!.
```
Two strings match if right before a space the letters before the space are swapped and the remainder if the strings match. We then use `!` to cut.
Our last case is if we are not next to a space the first two letters need to match.
```
p([A|U],[A|Y]):-p(U,Y).
```
[Answer]
# [Wolfram Language](http://reference.wolfram.com), 117 bytes
```
StringReplace[RegularExpression["\\b[[:alpha:]]{2,}\\b"]:>StringDrop[StringInsert["$0",StringTake["$0",{-1}],-3],-1]]
```
[Try it online!](https://tio.run/##JYvBasMwEETv/YpF9OjQpr0ZWhpISgs5FNeXouiwsTeWiCwJaY0Lxt/uKjXswM4bXo@sqUc2DS6Xl@Wbo3FdRcFiQ7KibrAYD78hUkrGOylOp7OUJdqgsVRqeirmTIQqX1dzH32Q6/vpEkWW4v5RFCup8UprnzbbWRWb55ytUstXXhkkXODhDSZRa3TpKgoQP36gCCPZxlN/A7U2CfKhAwzBUmZ3AOLdmhBM5@BIzJQi7KIfWncz@IPA71to9O5oD446GI1mSGP2WwL7L1RiBrX8AQ "Wolfram Language (Mathematica) – Try It Online")
Applied to the test strings.
```
StringReplace[
  RegularExpression["\\b[[:alpha:]]{2,}\\b"] :> 
   StringDrop[StringInsert["$0", StringTake["$0", {-1}], -3], -1]] /@
 {"Thansk", "Youer welcoem", "This is an apple", 
  "Flippign Lettesr Aroudn", "tHe oDd chALlEneg wiht swappde lettesR"} // Column
```
> 
> 
> ```
> Thanks
> Youre welcome
> Thsi si na appel
> Flipping Letters Around
> teH odD chALlEnge with swapped letteRs
> 
> ```
> 
> 
[Answer]
# [R](http://www.r-project.org), ~~111~~ ~~51~~ 41 bytes
Courtesy of @Giuseppe, a regex approach which blows my old method out of the water.
```
cat(gsub("(.)(.)\\b",'\\2\\1',scan(,"")))
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 28 bytes
```
1↓∊((¯2↓⊢),2↑⌽)¨' '(,⊂⍨⊣=,)⍞
```
`⎕ML` and `⎕IO` are both `1`, 
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v//Ud/UR20TDB@1TX7U0aWhcWi9EYjZtUhTB8iY@Khnr@ahFeoK6ho6j7qaHvWueNS12FZH81HvvP//g/NzU0syMvPSFYoS81LycxXS81OLFTJSi1IB "APL (Dyalog Classic) – Try It Online")
# Explanation
* **`... (,⊂⍨⊣=,) ...`** Split (while keeping borders, and appending a border to the beginning) ...
* **`... ⍞`** ... the input ...
* **`... ' ' ...`** ... at spaces.
* **`... ( ... )¨ ...`** Then, to each element of that:
	+ **`... , ...`** Concatenate ...
	+ **`... (¯2↓⊢) ...`** ... every item except the last two ...
	+ **`... 2↑⌽ ...`** ... with the reverse of the last two elements.
* **`1↓∊ ...`** Finally, return all but the first element of the flattened result.
[Answer]
# [Funky](https://github.com/TehFlaminTaco/Funky), 34 bytes
```
s=>s::gsub("(.)(.)( |$)","$2$1$3")
```
[Try it online!](https://tio.run/##SyvNy678n2b7v9jWrtjKKr24NElDSUNPE4QUalQ0lXSUVIxUDFWMlTT/FxRl5pVopGlk5usVpSamaGhqav4v8UhVyHdJUUjOcPTJcc1LTVcoz8woUSguTywoSElVyEktKUktDgIA "Funky – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 45 bytes
*-2 bytes thanks to H.PWiz.*
```
(r.g.r=<<).words
g(x:y:z)=' ':y:x:z
r=reverse
```
[Try it online!](https://tio.run/##DcY7DoQgEADQ3lNMjIlayAGIcwpbG4IDbhYXMvg/vLO@6s0mfykEcThKw8orxr5v1RF5yoVvTn3pu8Ua6jenvgtGpp04kyzm8wOEtK3DylCBg/KKGxMcFGxcqJTHumB8ls6m9Ac "Haskell – Try It Online")
[Answer]
# [J](http://jsoftware.com/), ~~20 19~~ 11 bytes
Credit to @Bolce Bussiere
```
1&A.&.>&.;:
```
[Try it online!](https://tio.run/##RYzBCgIhGITvPcWc1pvQtSgQKjrsKfbSUfTf1TIVdfHxbQlCmMvMNzOv1uYTx34QfODngR8PjZQJmMEmI31@s93fP8NKCZWcCvTp8WRsxibpIWN01MnN2Rjt4jFSKZQTRAqr9r1Q7oRw0VBGjO7qaUG1piDX7UgT3G/2YO0L)
```
       &.;:      on words
    &.>          on each
  A.             apply the permutation
1&               number 1, swap the last two elements
```
[Answer]
## [Alice](https://github.com/m-ender/alice), 24 bytes
```
/0RR'.%$1\' o
\ix*o ne@/
```
[Try it online!](https://tio.run/##S8zJTE79/1/fIChIXU9VxTBGXSGfKyazQitfIS/VQf///5CMzGIFIErMU0gsKMhJBQA "Alice – Try It Online")
### Explanation
```
/...\' o
\.../
```
This forms a loop where the loop body is a linear Ordinal snippet and we execute `' o` in Cardinal mode between every two loop iterations. The latter just prints a space.
Unfolding the zigzag structure of the Ordinal code, the linear loop body actually looks like this:
```
iR*' %e10xRo.n$@
```
Breaking this down:
```
i     Read all input. On subsequent iterations, this will push an empty string.
R     Reverse.
*     Join. On the first iteration, this joins the input to an implicit empty string,
      which does nothing. On subsequent iterations, it will join the empty string to
      the word on top of the string, thereby getting rid of the empty string.
' %   Split around spaces. On the first iteration, this will split the input
      into individual words. On subsequent iterations, this does nothing.
e10   Push "10".
x     Use this to permute the (reversed) word on top of the stack. In
      particular, the word is rearranged with the same permutation that is
      required to sort the string "10", which means the first two letters
      get swapped (which correspond to the last two letters of the actual
      word).
R     Reverse the swapped word.
o     Print it.
.n$@  If there are no words left on the stack, terminate the program.
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), ~~109~~ 100 bytes
Edit: don’t have to handle one letter words
```
,[>++++[-<-------->],]>+[-<[>++++[<++++++++>-]<[->>+<<]<]<<[->>+<<]>[[-<+>]>]<<[>+>+>]-<]>>>>>>>[.>]
```
[Try it online!](https://tio.run/##PYrBCoNADER/JfeYfkEYKLTQQ0@9hhysbqtUrNQVP39dcemby/Bmnr@6H19L80mpMnDGRKUArxy7KItyAeJqArCq5/w7LJ8Zjt2Bc1yyPbATPKV4C/S9tNR05/twHcOb1r6LNK/1NLWBhhBjmB8b "brainfuck – Try It Online")
Prints a trailing space
### How It Works
```
,[>++++[-<-------->],] Puts input on the tape and subtracts 32 from each character
                       This separates each word
>+[- Start the loop
   <[>++++[<++++++++>-]<[->>+<<]<] Add 32 to each letter of the word
                                   Skip this on the first iteration for the last word
   <<[->>+<<]>[[-<+>]>] Swaps the last two letters of the word
   <<[>+>+>]- If there is another word to the left continue loop
              Also set up to add a space to the end of the word
 <] End loop
 >>>>>>>[.>] Print the modified string
```
### Previous version, 109 bytes
```
,[>++++[-<-------->],]>+[-<[>++++[<++++++++>-]<[->>+<<]<]<<[[->>+<<]>[[-<+>]>]<<[<]]>[>]<[>+>+>]-<]>>>>>>[.>]
```
[Try it online!](https://tio.run/##NYu9DoJAEIRfZftjfYLNJCaaWFjZXrZAWIVIkMgRHv9YyPlNMz@Z56/ux9fSfHKuIoITWbgArRR7URYJBbBKZCCIqEviP8CdBCj2UtSzO3@7lH0@iCdozulm9L201HTn@3Ad7U1r3yWa13qaWqPBUrL5sQE "brainfuck – Try It Online")
[Answer]
# [QuadR](https://github.com/abrudz/QuadRS), 8 bytes
```
..\b
⌽⍵M
```
[Try it online!](https://tio.run/##KyxNTCn6/19PLyaJ61HP3ke9W33//w/JSMwrzuaKzC9NLVIoT81Jzk/N5QrJyCxWAKLEPIXEgoKcVC63nMyCgsz0PAWf1JKS1OIiBcei/NKUPK4Sj1SFfJcUheQMR58c17zUdIXyzIwSheJyoLaUVIUcsOogAA "QuadR – Try It Online")
[Answer]
# Google Sheets, 33 Bytes
Anonymous worksheet function that takes input from cell `A1` and outputs to the calling cell
```
=RegExReplace(A1,"(.)(.)\b","$2$1
```
-2 Bytes Thanks to [@KevinCruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen) for the use of `(.)` over `(\w)`
[Answer]
# [Julia 1.0](http://julialang.org/), 30 bytes
```
!s=replace(s,r"..\b"=>reverse)
```
[Try it online!](https://tio.run/##HY1BCsIwEEX3OcU0qxZKwAO0UFBx0ZW4EbqJ7dBGx2nIpNaFd49V@KvHe/z7Qs7u3illUgX0ZHvMpQzamO6mqzrgC4NgkWyltVaXybI81HVeMMCK1M/43KAT2GYZrPeE6kjOezcytBgjSoAmzMvAKp4Q5v0A/dS0dGAcYXVTBFm3bECgv31WvyNlMvHkYm5L3bEuwHxq8MFxJE5f "Julia 1.0 – Try It Online")
detect end of words with a regex `r"..\b"` and apply `reverse` on the matches
[Answer]
# Curry, 33 bytes
Tested in both [KiCS2](https://www-ps.informatik.uni-kiel.de/kics2/) and [PAKCS](https://www.informatik.uni-kiel.de/%7Epakcs/).
```
f(u++[x,y])=u++[y,x]
(>>=f).words
```
Curry's powerful patterns let it beat [the Haskell answer](https://codegolf.stackexchange.com/a/151919/56656)!
To test it you can use [Smap](https://smap.informatik.uni-kiel.de/smap.cgi?new/curry). Just select `KiCS2 2.2.0` or `PAKCS 2.2.0` and paste the following complete code:
```
f(u++[x,y])=u++[y,x]
g=(>>=f).words
main=f "Hello world an happy day"
```
[Answer]
# [Perl 5](https://www.perl.org/), 19 + 1 (`-p`) = 20 bytes
```
s/(\w)(\w)\b/$2$1/g
```
[Try it online!](https://tio.run/##K0gtyjH9/79YXyOmXBOEY5L0VYxUDPXT//8PycgsVgCiRIWS1OKSf/kFJZn5ecX/dX1N9QwMDf7rFgAA "Perl 5 – Try It Online")
[Answer]
# [PHP](https://php.net/), 119 107 bytes
Edit: thanks to totallyhuman
```
<?php foreach(explode(" ",trim(fgets(STDIN)))as$w)echo substr($w,0,strlen($w)-2).strrev(substr($w,-2))," ";
```
[Try it online!](https://tio.run/##RYxBCsIwEEWvMpQuZiCKuFUQQQRB3OgFajttAmkyTFLr7WN27t5/fJ5YKeV4EiswRuWut8hf8XFgbKAxWd2M48Q54fN1uT2IqEvtStzbCGl5p6zYrmZnKngOlWmzp21dyh/8H6okU4OHUq7eibgpwJ1z5qRw1rgM4Qc "PHP – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 41 bytes
```
foldr(%)" "
a%(b:' ':r)=b:a:' ':r
a%s=a:s
```
[Try it online!](https://tio.run/##JYtBi8IwFITv/oohrKjg/oFCD4KKh3rZ9bKoh2f72gRfk5Ck9N9vjLswh5lvZjTFJ4vkvr7l3kkX1suNglrQcv2oVlhVYVM/Kvq3hcaaqphHMhY1RvJn@Cl9p9BYfLwzelzVRZONT7VVP27igJmldTyWfNEmoogsyHvhgo5ivDeDRcMpcQzYBTd1tjTpxHD7Dq3eNXKwPGA2OiHO5dox5G//pe75t@2Fhpg/W@9f "Haskell – Try It Online")
Outputs with a trailing space.
The repeated `' ':r` looks wasteful. But `a%(b:t@(' ':r))=b:a:t` is the same length and `a%(b:t)|' ':_<-t=b:a:t` is one byte longer.
---
# [Haskell](https://www.haskell.org/), 41 bytes
```
f(a:b:t)|t<"A"=b:a:f t|1>0=a:f(b:t)
f e=e
```
[Try it online!](https://tio.run/##HYtBi8IwFITv@yuG4MGFFfRa7EJBxUO9qJdF9vBsX5pgmobmlV787Wbjwhxm5psxFB/sXEp6ScW9kM@nbFWlyntBhYY8N9/rMrvlG31ocMmpJ@tRoqdwQpjkImPtsXhnaNzU1ZCPD/WlfoaJR8zsmoH7nK/GRmSRB4XgOFcHZ0OwnUfNIhxHVOMwtT4TOTKGXYvGVLXbe@4wWyOIc762DPe/P6vf9Gq0oy6mVRPCHw "Haskell – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~53~~ 45 bytes
```
u[a,b]=[b,a]
u(a:b)=a:u b
unwords.map u.words
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/vzQ6UScp1jY6SScxlqtUI9EqSdM20apUIYkrzbY0rzy/KKVYLzexQKFUD8z@n5uYmWdbUJSZV6KSpuQBNCJfITy/KCdF6T8A "Haskell – Try It Online")
## Explanation
`u` is a function that swaps the last two letters of a word. To apply it to all the words we use `words` to split the list, map it across all of the words and then use `unwords` to put it back together.
[Answer]
# [sed](https://www.gnu.org/software/sed/), ~~20~~ 17+1 (-r) = 18 bytes
```
s/(.)(.)\b/\2\1/g
```
[Try it online!](https://tio.run/##K05N0U3PK/3/v1hfQ08TiGKS9GOMYgz10///D8nILFYAosQ8hcSCgpxUrn/5BSWZ@XnF/3WLAA "sed – Try It Online")
[Answer]
# PHP, 65 bytes
requires PHP 7.1 (or later)
```
for(;$s=$argv[++$i];$s[-1]=$s[-2],$s[-2]=$c,print"$s ")$c=$s[-1];
```
takes sentence as separate command line arguments. Run with `-nr`.
---
working on a single string, **77+1 bytes**:
```
foreach(explode(" ",$argn)as$s){$c=$s[-1];$s[-1]=$s[-2];$s[-2]=$c;echo"$s ";}
```
Run as pipe with `-nR`.
---
[Answer]
# Java 8, 35 bytes
```
s->s.replaceAll("(.)(.)\\b","$2$1")
```
Port of [*@TaylorScott*'s Google Sheets answer](https://codegolf.stackexchange.com/a/152412/52210), after I golfed two bytes. EDIT: I see it's now a port of [*Neil*'s Retina answer](https://codegolf.stackexchange.com/a/151947/52210) after my two golfed bytes.
**Explanation:**
[Try it online.](https://tio.run/##hY5PS8NAEMXv/RSPpYcEbECvRSGg4qH2oL2I9bDdjMm2m9lld9Mgks8e15qrBN7A/PvNm6M8y5V1xMfqNCojQ8Cz1Py9ADRH8p9SEba/JfAaveYaKpuSkK9Tf0iRFKKMWmELxi3GsLoLhSdnEl4ak4msyJP2@4O4Esub5bXIx/Uf6LqDSeDEn62u0KYPJpP3D8h8sv8KkdrCdrFwaRQNZ1yoTOwayeEk8ss3/6@92Y48ejLKUju7vWt0QJJkSOcMzQKPRjuna8aGYqTgUXrbVTzLxSeCva@gmnJjHphq9LqJCH2yrQjmcu1lOjMshvEH)
```
s->                           // Method with String as both parameter and return-type
   s.replaceAll("(.)(.)       //  Replace any two characters,
                       \\b",  //  with a word-boundary after it (space or end of String)
                "$2$1")       //  With the two characters swapped
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~38~~ ~~36~~ 32 bytes
```
~~s=>s.replace(/(.)(.)( |$)/g,"$2$1 ")~~ 
```
```
s=>s.replace(/(.)(.)\b/g,"$2$1")
```
[Try it online!](https://tio.run/##bYyxCsIwFEV3v@JROiSgLbpKhYKKQyfp4hiS1yQak5CkdvHfY3WUwtnuuefOXizyoH3aWCcwD02OzSFWAb1hHElNKvoF3iWt5bood@UWCpr33NnoDFbGSTKQolfMxkdB6ep/ubkRA0xouMPnktArHWGGWWDeG1xyzkZ7r6WFDlPCGKANbhR2SU0XBHcUwFXbmZNFCZNWCeI0xwWC@QWu8zN/AA "JavaScript (Node.js) – Try It Online")
RegExp approach courtesy @Giuseppe (although I thought of this independently), assuming words separated by only one space
-2 for only considering 1 space and add trailing space
-4 Thanks @Shaggy
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~23~~ 22 bytes
```
" "/{x@prm[!#x]1}'" "\
```
[Try it online!](https://tio.run/##y9bNz/7/X0lBSb@6oCg3uiLWsFYdyItRcsvJLCjITM9T8EktKUktLlJwLMovTclT@v8fAA "K (oK) – Try It Online")
**Example:**
```
" "/{x@prm[!#x]1}'" "\"Hello World"
"Helol Wordl"
```
**Explanation:**
Port of [FrownyFrog](https://codegolf.stackexchange.com/a/151933/69200)'s solution to save **1 byte**. 
I'll come back to this.
```
" "/{prm[x]1}'" "\ / the solution
              " "\ / split input on " "
    {       }'     / apply lambda to each
     prm[x]        / permute input x
           1       / and take the 2nd result
" "/               / join with " "
```
**Previous solution:**
* `" "/-2{(x_y),|x#y}'" "\` **23 bytes**
]