[Question]
  [
I'm sure most, if not all, of you have [come across this](http://www.mrc-cbu.cam.ac.uk/people/matt.davis/Cmabrigde/) at some point or another:
> 
> Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
> in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
> taht the frist and lsat ltteer be at the rghit pclae. The rset can be
> a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
> bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
> wrod as a wlohe.
> 
> 
> 
* Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.
* The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.
* All other formatting must remain the same (capitalization and punctuation, etc.).
Testing text:
> 
> According to a researcher at Cambridge University, it doesn't matter
> in what order the letters in a word are, the only important thing is
> that the first and last letter be at the right place. The rest can be
> a total mess and you can still read it without problem. This is
> because the human mind does not read every letter by itself but the
> word as a whole.
> 
> 
> 
As usual, this is a code-golf. Shortest code wins.
  
[Answer]
## Ruby - 50 48 chars, plus `-p` command line parameter.
```
gsub(/(?<=\w)\w+(?=\w)/){[*$&.chars].shuffle*''}
```
Thanks @primo for -2 char.
## Test
```
➜  codegolf git:(master) ruby -p 9261-cambridge-transposition.rb < 9261.in
Acdrcinog to a racreseher at Cagribmde Ursvetniiy, it dsoen't mttaer in waht odrer the leertts in a word are, the olny ionarpmtt tnhig is that the fsirt and last letetr be at the rghit pcale. The rset can be a taotl mses and you can slitl raed it wthiuot perlbom. Tihs is buaecse the hmuan mind does not raed ervey lteetr by ietlsf but the word as a wlhoe.
```
[Answer]
## PHP 84 bytes
```
<?for(;$s=fgets(STDIN);)echo preg_filter('/\w\K\w+(?=\w)/e','str_shuffle("\0")',$s);
```
Using a regex to capture words that are at least ~~4~~ 3 letters long†, and shuffling the inner characters. This code can handle input with multiple lines as well.
If only one line of input is required (as in the example), this can be reduced to **68 bytes**
```
<?=preg_filter('/\w\K\w+(?=\w)/e','str_shuffle("\0")',fgets(STDIN));
```
---
† There's only one letter in the middle, so it doesn't matter if you shuffle it.
[Answer]
# Python, 118
Python is terribly awkward for things like this!
```
from random import*
for w in raw_input().split():l=len(w)-2;print l>0and w[0]+''.join((sample(w[1:-1],l)))+w[-1]or w,
```
### Bonus
I tried some other things that I thought would be clever, but you have to import all sorts of things, and a lot of methods don't have return values, but need to be called separately as its own statement. The worst is when you need to convert the string to a list and then `join`ing it back to a string again.
Anyways, here are some of the things that I tried:
Regex!
```
import re,random
def f(x):a,b,c=x.group(1,2,3);return a+''.join(random.sample(b,len(b)))+c
print re.sub('(\w)(\w+)(\w)',f,raw_input())
```
Permutations!
```
import itertools as i,random as r
for w in raw_input().split():print''.join(r.choice([x for x in i.permutations(w)if w[0]+w[-1]==x[0]+x[-1]])),
```
You can't shuffle a partition of a list directly and `shuffle` returns `None`, yay!
```
from random import*
for w in raw_input().split():
 w=list(w)
 if len(w)>3:v=w[1:-1];shuffle(v);w[1:-1]=v
 print ''.join(w),
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 10 bytes
```
?V`\B\w+\B
```
[Try it online!](https://tio.run/##PZBNTsQwDIWv4h0LRiNxAsRwBWDVBW7qaSzlZ2Q7VD19cVKElIXj9/LZL0LGBV@O4/Xre7pN2/N0O463EKosXFawCghCSighkgAavGOehZeV4LPwD4my7Rdgg6WSlieDjGZu5QJbdL@T/GaRIFEXtCsIm/cBhS5DqiXtwPlRxbCYt/pwVi/QhuHOogZYFkjoxYmCmeBPF16jwSNhoCt89Aa5LWAZHs9hmCCT6mDstQ1NjVNyKy49wMYWa3OK1DlR7hxfwc9MAZvSGBRb9oeZndIDQ6l2Asj/Yv9fzNOYUrrD3M4Fz7zak8ea6PoL "Retina – Try It Online")
Hey, this old challenge was made for the new Retina!
### Explanation
`\B\w+\B` matches groups of letters between non-boundaries, that is groups of letters that don't begin or end a word. Since regexes are greedy, this will match all the letters of a word except the first and the last one.
`V` is the "reverse" stage, that reverses the order of characters in each match of the regex. With the `?` option it scrambles them instead.
[Answer]
## J (48)
```
''[1!:2&4('\w(\w+)\w';,1)({~?~@#)rxapply 1!:1[3
```
Explanation:
* `1!:1[3`: read all input from stdin
* `rxapply`: apply the given function to the portions of the input that match the regex
* `({~?~@#)`: a verb train that shuffles its input: `#` counts the length, this gets applied to both sides of `?` giving N distinct numbers from 0 to N, `{` then selects the elements at those indices from the input array.
* `('\w(\w+)\w';,1)`: use that regex but only use the value from the first group
* `[1!:2&4`: send unformatted output to stdout
* `''[`: suppress formatted output. This is necessary because otherwise it only outputs that part of the output that fits on a terminal line and then ends with `...`.
[Answer]
## [Nibbles](http://golfscript.com/nibbles), 15 bytes
This was a little awkward since nibbles doesn't have shuffle or even randomness (nor does it have regex).
```
+.%~@ \$a
  :@
    ::`($
      ++=~
        `)\`'$
        `# $ 0
      $
```
(Nibbles isn't on TIO yet). But use it like:
```
> nibbles cambridge.nbl < input.txt
Aoinrccdg to a raeeercshr at Caibrmgde Uvteiinrsy, it doesn't mttaer in waht oerdr the ltteers in a word are, the olny itoanrmpt tinhg is taht the first and last ltteer be at the rihgt palce. The rest can be a ttoal mess and you can stlil raed it wutoiht poelbrm. Tihs is buaecse the huamn mind does not raed every ltteer by itelsf but the word as a wolhe. 
```
That's the literate form which is 30 nibbles.
That last $ could be left out but there is no point since this program is 30 nibbles (it would be 29 half bytes then rounded up)
### How?
```
+.%~@ \$a          concat the map of the split by alpha numeric chars
  :@               append the value that preceded the split match
    ::`($          append the first value of the match to
      ++=~         concat the concat of the group by of
        `)\`'$     the tail of the reverse of the transpose of the tail of the match
        `# $ 0     hash of the char (0 says range is infinite)
      $            the head of the reversed thing from earlier
```
Essentially it selects groups of alphanums, then selects the inner part of that using uncons twice. Then for randomness does a group by (which also sorts by) the hash of a character.
The transpose part is so that doing uncons on an empty string returns an empty string instead of null character (which becomes a space). You could leave it out but you'd get an extra space on 1 letter words like "a".
[Answer]
## APL 107
Unfortunately my APL interpreter does not support regexs so here's a home rolled version where the text to be scrambled is stored in the variable t:
```
⎕av[((~z)\(∊y)[∊(+\0,¯1↓n)+¨n?¨n←⍴¨y←(~z←×(~x)+(x>¯1↓0,x)+x>1↓(x←~53≤(∊(⊂⍳26)+¨65 97)⍳v←⎕av⍳,t),0)⊂v])+z×v]
```
Essentially the code partitions the text into words based on the letters of the alphabet only and then into the letters between the first and last letters of those words. These letters are then scrambled and the whole character string reassembled.
[Answer]
## APL, ~~58~~ 49
I believe this works in IBM APL2 (I don't have IBM APL)
```
({⍵[⌽∪t,⌽∪1,?⍨t←⍴⍵]}¨x⊂⍨~b),.,x⊂⍨b←' ,.'∊⍨x←⍞,' '
```
---
If not, then in Dyalog APL, add to the front:
```
 ⎕ML←3⋄
```
which adds 6 chars
---
[Answer]
## VBA, 351 373/409
```
Sub v(g)
m=1:Z=Split(g," "):j=UBound(Z)
For u=0 To j
t=Z(u):w=Len(t):l=Right(t,1):If Not l Like"[A-Za-z]" Then w=w-1:t=Left(t,w):e=l Else e=""
If w>3 Then
n=Left(t,1):p=w-1:s=Right(t,p):f=Right(t,1)
For p=1 To p-1
q=w-p:r=Int((q-1)*Rnd())+1:n=n & Mid(s,r,1):s=Left(s,r-1) & Right(s,q-r)
Next
Else
n=t:f=""
End If
d=d & n & f & e & " "
Next
g=d
End Sub
```
Alternate (larger) Method:
```
Sub v(g)
m=1:Z=Split(g," "):j=UBound(Z)
For u=0 To j
t=Split(StrConv(Z(u),64),Chr(0)):w=UBound(t)-1:l=Asc(t(w)):If l<64 Or (l>90 And l<97) Or l>122 Then e=t(w):w=w-1 Else e=""
If w>3 Then
n=t(0):p=w-1:s=""
For i=-p To -1
s=t(-i) & s
Next
f=t(w)
For p=1 To p-1
r=Int((w-p)*Rnd())+1:n=n & Mid(s,r,1):s=Left(s,r-1) & Right(s,w-p-r)
Next
n=n & s
Else
n=Z(u):f="":e=""
End If
d=d & n & f & e & " "
Next
g=d
End Sub
```
Both of these methods change the value of the variable passed to the `Sub`. i.e.
```
Sub Test()
strTestString = "This is a test."
v strTestString
Debug.Print strTestString
End Sub
```
will output something like this:
```
"Tihs is a tset."
```
Also, this does randomize mid-word punctuation, so this may not fit the spec 100%.
[Answer]
# APL NARS 172 chars
```
r←g x;i;s;d;k
s←⎕AV[98..123]∪⎕A
i←1⋄v←''⋄r←''⋄k←⍴x
A:d←''⋄→C×⍳i>k⋄d←x[i]⋄→C×⍳∼d∊s⋄v←v,d⋄i+←1⋄→A
C:v←{t←¯2+⍴r←⍵⋄t≤1:r⋄r[1+t?t]←⍵[1+⍳t]⋄r}v
r←∊r,v,d
v←''⋄i+←1⋄→A×⍳i≤k
g x←⍞
```
13+17+18+44+41+8+17+5+9=172;
This function g() has input as a string; has output as a string. I add the input command because i don't know how insert \' in a quoted string. Commented
```
∇r←g x;i;s;d;k
   ⍝ words are element of  a-zA-Z separed from all other
   s←⎕AV[98..123]∪⎕A ⍝a-zA-Z ascii ⎕IO = 1
   i←1⋄v←''⋄r←''⋄k←⍴x
A:   d←''⋄→C×⍳i>k⋄d←x[i]⋄→C×⍳∼d∊s⋄v←v,d⋄i+←1⋄→A
C:      v←{t←¯2+⍴r←⍵⋄t≤1:r⋄r[1+t?t]←⍵[1+⍳t]⋄r}v
        r←∊r,v,d
        v←''⋄i+←1⋄→A×⍳i≤k
∇
```
result
```
g x←⍞
According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole.
  Androiccg to a rhraeecser at Cgirbdmae Uirevtsiny, it deson't mtetar in waht oderr the ltrtees in a wrod are, the olny intro
  apmt tinhg is taht the frsit and lsat lteter be at the rghit pacle. The rset can be a ttaol mses and you can siltl rae
  d it wtuhoit poeblrm. Tihs is bcsauee the hmaun mnid deos not raed eervy lteter by isletf but the wrod as a wolhe.
```
[Answer]
# PHP 7.1, not competing, 80 bytes
```
for(;$w=$argv[++$i];)echo$w[3]?$w[0].str_shuffle(substr($w,1,-1)).$w[-1]:$w," ";
```
takes input from command line arguments. Run with `-nr`. (will obviously fail at punctuation)
[Answer]
# PHP, 94+1 bytes
+1 for `-R` flag
```
<?=preg_replace_callback("/(?<=\w)\w+(?=\w)/",function($m){return str_shuffle($m[0]);},$argn);
```
Pipe input through `php -nR '<code>'`.
Note:
`preg_replace_callback` came to PHP in 4.0.5;
closures were introduced in php 5.3;  
so this requires PHP 5.3 or later.
Unfortunately, the match is always sent as an array, even if there are no sub patterns,  
thus I cannot just use `str_shuffle` as the callback, which would save 29 bytes.
[Answer]
# JavaScript, ~~76~~ 67 bytes
thanks to [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld) for -9 bytes.
```
t=>t.replace(/\B\w+\B/g,m=>[...m].sort(_=>Math.random()-.5).join``)
```
[Try it online!](https://tio.run/##PVC7bsMwDPwVIkttNFGmjg7QdO7WTk3R0DJtKdAjkOgY/nqXsosCGije8XjHGz4w62TvfAixo6VvFm5OrBLdHWqqjpfzZXq@nI/D3jenL6WU/1Y5Jq5@mtM7slEJQxd9VR/US61u0YbrtV50DDk6Ui4OVV/tXrWOqbNhAI6AkCgTJm0oATK8oW@T7QaCz2AflLLleQ@WoYuUwxODR2ah2gCTEb4oyY8NgaMC5IIgTNIHTLRfoRjcDNbfxSkGllZZbrMUyCuhtykziHdwKMUmBS3BH57sYBjWIyj4KA0SmsawciQHowNPOa8acxxXLLN1TqjYlQCTZRNHUUmxdeSLjliQ15LGMdO6yIxeBr0VlRIYQuRNgOQW878xScOZXA/tuBnc8uaS3JRT7@p6@QU "JavaScript (Node.js) – Try It Online")
---
## Ungolfed
```
t =>                  // function with a single argument
     t.replace(       // Replace ...
         /\B\w+\B/g,  // every match of the regex
         m => ...     // with the return value of the replacement function
     )
/       /g            // Match all occurences of
   \w+                // 1 or more word chars ...
 \B   \B              // ... that aren't on the beginning or end of the word
m =>                  // Replacement function
     [...m]           // convert matched string to a list of chars
       .sort(_ => Math.random()-.5) // sort with a random comparision function
       .join``        // join the list into a single string
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~22~~ 20 bytes
```
e€ØẠ+ƝỊŻœṗµḢ,ṪjW)ẎẊ€
```
[Try it online!](https://tio.run/##PZA9TsNAEIWvMh1CRLkD4gog6rE98U60P9HuGMstZQoaCmiQECWiRSJJBwr3WC5iZm2EtMXsvLffzNs1WTuMI/3cvn095v3z2fdTPmyPh@N93j18vuePl0Xeva6vT/P@Lu@3ahvH8byuQ2zYtyABECIlwlgbioACF@iqyE1LcOX5hmJiGRbAAk2g5E8EHIqolT30Rv1K0psYAktFSEVB6LUPGGkxScHbAdhtQhT0oq0ynJMWKJNhxTEJoG/AohYzCiqCPz1yawQ2FmtawmVpkNpq9JNHcwhacJTSxBhCN2lJ2Fq1YlMC9CwmdEqJobLkCkdX0FNRjV2iaZDpnD50rJQSGHyQGUD6F8P/YppGEtkVVN284Jw3leQmWFr@Ag "Jelly – Try It Online")
This was fun to make.
Each non-alphabet character is grouped into a single character string, and the first and last characters of each word are grouped the same way as well. That way, taking a random permutation of those characters will not change their order.
Made with a lot of help from caird coinheringaahing.
-2 bytes from caird coinheringaahing.
## Explanation
```
e€ØẠ+2\ỊŻœṗ⁸µḢ,ṪjW)ẎẊ€ 
 €                     for each character:
e ØẠ                   check if it's in the alphabet
    +2\                add overlapping pairs
       Ị               check if they are ≤ 1
        œṗ⁸            and partition the input using that bitmask
           µ      )    execute the following on each part:
            Ḣ,ṪjW      get head, tail, and join with the modified list
                   Ẏ   join the list of triplets together
                    Ẋ€ get a random permutation of each of the elements
```
[Answer]
# [Python 3](https://docs.python.org/3/), 113 bytes
*based on the original [python answer](https://codegolf.stackexchange.com/a/9355/86751) by [daniero](https://codegolf.stackexchange.com/users/4372/daniero)*
```
import re,random
print(re.sub('(\w)(\w+)(\w)',lambda m:m[1]+''.join(random.sample(m[2],len(m[2])))+m[3],input()))
```
[Try it online!](https://tio.run/##PVDLboQwDLz3K3wDtAip3VtvVX@hPdE9GPBuXOWBEqeIr6dOqColke0Zjz1ZdzHBX4@D3RqiQKQ@ol@Ce1oje2kjDSlPbdN@bZ3eS3m6prfopgXBvbrx@XZpmuE7sG/PziGhWy21bny59ZZ8Dbquu7jxeuvZr1laTY/jbZ5DXNg/QAKgjk6EcTYUAQXedULk5UHw6fmHYmLZe2CBJVDyjYBDEaWyh80oX5U0E0NgqQCpIAib1gHVVYWCtzucTtGLlspwThqgVMKdYxJQG2BRg1MKJoI/PPLDCKwWZxrgoxRIaTP6ylEfghYcpVQ19pArloStVSouxcDG@uVZVWKYLLmioyvomWjGnKgOMtlpo2NVKYbBBzkFSP9i/19M3Ugie4cpnwueflNxboKl4Rc "Python 3 – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), ~~15 14~~ 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
â#]ø\┘‼↕ip2╚_
```
[Run and debug it](https://staxlang.xyz/#p=83235d005cd91312697032c85f&i=According+to+a+researcher+at+Cambridge+University,+it+doesn%27t+matter+in+what+order+the+letters+in+a+word+are,+the+only+important+thing+is+that+the+first+and+last+letter+be+at+the+right+place.+The+rest+can+be+a+total+mess+and+you+can+still+read+it+without+problem.+This+is+because+the+human+mind+does+not+read+every+letter+by+itself+but+the+word+as+a+whole.)
Regex is busted.
-2 bytes from recursive.
[Answer]
# [R](https://www.r-project.org/), 159 bytes
```
function(x){l=attr(w<-el(gregexpr("[a-zA-Z]+",x)),"m")
Map(function(i,j)substr(x,i,j)<<-Reduce(paste0,sample(substring(x,r<-i:j,r))),s<-w[l>3]+1,s+l[l>3]-3)
x}
```
[Try it online!](https://tio.run/##bZJPb5xADMXvfAqLS0E7RK1yq9hIUc@9VO2lUVSZwQsTzR80NoVt1c@@NZDmVImDx@/5jX9AvlkMXXb9QD8kY@QpMZ1vlzlacSlWa/3bn1EkV0vbkK@GTAOtU67KJ2x@PTbfn0@lWevalKGsi884VW@jzrzUPHess6vZDm3bfKF@tlRNyELvDWOYPFWHycVBfblt3McXk2uN5LZZnvzD/fPpg@GT38vmvi7WP7fDfy4frU251xIkAUImJsx2pAwo8OkfGXyL7idldnI14AT6RBzfCQQFU6uLsIzq1yQ9yUjgaRN4UxAW7QNmMruUor@CC1PKglG0tV3uWAuU3XBxmQUw9uCV8jUKOoJXPbthFJg8WrqDr1uD1GYx7h7lEPQQiHnPuKZ511ic92rFfgNYnIxp1pScOk9hy9EV9OnI4sy0XzTOQQeD05QNGGKSI4D0XVzfFlMaYfIX6OZjwYOXN/Ixebori@I//0h1fIK6uP0F "R – Try It Online")
Posted before realizing that there was already [another](https://codegolf.stackexchange.com/a/9321/95126) [R](https://www.r-project.org/) answer, but pleasingly the two approaches are quite different...
**Ungolfed code:**
```
cambridge_transpose=
function(x){                        # x is the input string,
  w=el(gregexpr("[a-zA-Z]+",x))     # w gets the words in x using a regex,
  l=attr(w,"match.length")          # l gets the lengths of each word,
  s=w[l>3]+1                        # s is the start letter to jumble in each word,
  e=s+l[l>3]-3                      # e is the end letter to jumble in each word.
  Map(function(i,j) ... ,s,e)       # Now, use this function on all elements i,j from s,e:
    substr(x,i,j)<<-                #   replace letters in x from i to j
      Reduce(paste0,                #   with these letters joined-together:
        sample(                     #     a random sample of
          substring(x,r<-i:j,r)))   #     the letters in x from i to j.
x}                                  # Finally, return (modified) x.
```
[Answer]
# Python3, 110 bytes:
```
lambda x:re.sub('(?<=\w)\w{3,}(?=\w)',lambda x:''.join(r.sample(g:=x.group(),len(g))),x)
import re,random as r
```
[Try it online!](https://tio.run/##PVDLboQwDLz3K6y9ECTEZS/Vqquq6i@0t70YMJAqD@SYsqjqt1MHqpVycDzj8YynVcYYzs8Tb/31tjn0TYdwvzDVaW5MYV5frrelvC0/5@rXvOa6qB6soqi/og2G64R@cmSGy/VeDxznyZSVo2CGsiyre/lk/RRZgKliDF30gAl4m9gGMb05nU5vbRu5s2EAiYBKTITcjsSAAu@6kG03EHwG@02crKwVWIEuUgqFgEcRpdoAy6h8VdKfjASOMpAygrBoH1A97FAMboXDFwbRVl5ukxYoO6G3nATULjjU4pCChuAfZzuMApPDlmr4yA1SWoth52gOQQeeUto11jjvWBLrnFKxywEWq/efVYVj48hnHbWgr6EW50T7onH2OuitquTAEKIcAqS3WB/GNI0kcj0082HwyJty8jE6qvXMZbn9AQ)
[Answer]
## R, 179
Using the function I wrote for the [randomize letters in a word problem](https://codegolf.stackexchange.com/questions/3293/how-to-randomize-letters-in-a-word):
Input:
```
s <- "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole."
```
Solution:
```
f=function(w){l=length;s=strsplit(w,"")[[1]];ifelse(l(s)<3,w,paste(c(s[1],sample(s[2:(l(s)-1)]),s[l(s)]),collapse=""))}
g=Vectorize(f)
paste(g(strsplit(s," ")[[1]]), collapse=" ")
```
Result:
```
[1] "Arioccdng to a reehaecrsr at Cabrgimde Uveirisnyt, it des'not mttear in waht odrer the lttrees in a wrod are, the olny inpotmart thnig is that the fsrit and lsat letetr be at the right palce. The rset can be a toatl mses and you can stlil raed it wutioht pmrlebo. This is bsuceae the hmuan mnid deos not read ervey lteetr by iesltf but the word as a wleho."
```
[Answer]
# Pyth, 23 bytes
```
jdm?gld4++hd.<Ptd1eddcz
```
Non-competing because Pyth was made after this challenge was posted.
[Try it online](http://pyth.herokuapp.com/?code=jdm%3Fgld4%2B%2Bhd.%3CPtd1eddcz&input=According+to+a+researcher+at+Cambridge+University%2C+it+doesn%27t+matter+in+what+order+the+letters+in+a+word+are%2C+the+only+important+thing+is+that+the+first+and+last+letter+be+at+the+right+place.+The+rest+can+be+a+total+mess+and+you+can+still+read+it+without+problem.+This+is+because+the+human+mind+does+not+read+every+letter+by+itself+but+the+word+as+a+whole.&debug=0)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 32 bytes
```
m@Xl ¨4?Xg0 +Xs1J ö(x) +XgJ:X}" 
```
[Try it online!](https://tio.run/##PZBNTsQwDIWv8jQbQIxGILFiA2h2swapW7f1NEb5GSUuQxfchxNwADhYcVqElIXj9/LZL6900nkOj43H9@fdQzPc4Loptwf8fF2@X1k9HO6bjw3mefPUdSn3EgdoAiFzYcqd4wxS7Cm0WfqB8RLljXMRnbYQRZ@4xAtFIFWzSsTZmd9IdlPH8FyFUhXC2fqgzNtFStFPkHBKWSmqtepwKVaQLoaj5KKg2MOTFSsKLeNPzzI4xclTxzs81wabraO4eCyHkkfgUhbGlMZFKyrem5X6GuAs6tJolJxaz6FybAU7LXc0Fl4GuTHYwyBGqYERk64Atr@Y/hezNFrYH9GO64Jr3lKTu@R5t/kF "Japt – Try It Online")
[Answer]
**Java, ~~1557~~ 834 bytes**
Thanks to @JoKing for tips.
A bit late to the competition. Forgot that I had started on this problem.
**Golfed**
```
import java.util.*;public class s{ public static void main(String[] args){ Scanner s=new Scanner(System.in);String a=s.next();String[] q=a.split("\\s+");for (int i=0;i<q.length;i++) { q[i]=q[i].replaceAll("[^\\w]", ""); }String f="";for (String z:q) { f+=scramble(z);f+=" "; }System.out.print(f); }private static String scramble(String w){if(w.length()==1||w.length()==2){return w;}char[]l=w.toCharArray();char q=l[w.length()-1];String e=Character.toString(l[0]);char[]n=new char[l.length-2];for(int i=0;i<l.length-2;i++){n[i]=l[i+1];}HashMap<Integer,Character>s=new HashMap<>();int c=1;for(char p:n){s.put(c,p);c++;}HashMap<Integer,Integer>o=new HashMap<>();Random z=new Random();for(int i=0;i<w.length()-2;i++){int m=z.nextInt(n.length);while(o.getOrDefault(m,0) == 1){m=z.nextInt(n.length);}e+=s.get(m+1);o.put(m,1);}return e+=q;}}
```
**Non-golfed**
```
import java.util.HashMap;
import java.util.Random;
public class SentenceTransposition {
    public static void main(String[] args) {
        String input = "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole.";
        String[] words = input.split("\\s+");
        for (int i = 0; i < words.length; i++) {
            words[i] = words[i].replaceAll("[^\\w]", "");
        }
        String finalsentence = "";
        for (String word : words) {
            finalsentence += scramble(word);
            finalsentence += " ";
        }
        System.out.println(finalsentence);
    }
    private static String scramble(String word) {
        if (word.length() == 1 || word.length() == 2) {
            return word;
        }
        char[] letters = word.toCharArray();
        char lletter = letters[word.length()-1];
        String endword = Character.toString(letters[0]);
        char[] nletters = new char[letters.length-2];
        for (int i = 0; i < letters.length-2; i++) {
            nletters[i] = letters[i+1];
        }
        HashMap<Integer, Character> set = new HashMap<>();
        int count = 1;
        for (char nletter : nletters) {
            set.put(count, nletter);
            count++;
        }
        HashMap<Integer, Integer> chosen = new HashMap<>();
        Random random = new Random();
        for (int i = 0; i < word.length()-2; i++) {
            int cur = random.nextInt(nletters.length);
            while (chosen.getOrDefault(cur,0) == 1) {
                cur = random.nextInt(nletters.length);
            }
            endword += set.get(cur+1);
            chosen.put(cur, 1);
        }
        return endword += lletter;
    }
}
```
[Answer]
# [Sidef](https://github.com/trizen/sidef), ~~89~~ 85 bytes
Block (anonymous callable):
```
{.words.map{[_[0],(_.len-1?([_[1..^(_.len-1)]].shuffle...,_[1]):'')].join}.join(' ')}
```
Output, when used like `{ ... }('..')`: 
```
 I hvae nveer not ocne in my life slleepd nhedatarnel crtreolcy
 I have never not once in my lfie sepelld naetadenrhl ccrtloery
```
Somewhat ungolfed 
```
.words.map{
  [
    .first,
    (_.len-1
      ? (  [ _[1..^(_.len-1)] ].shuffle..., .last )
      : '')
  ].join
}.join(' ')
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 74 bytes
```
s|\pL\K\pL{2,}(?=\pL)|$,=$q=$&;$q=join'',shuffle$,=~/./g while$,eq$q;$q|ge
```
[Try it online!](https://tio.run/##PVHBTsMwDP0VHyoGUtcNpF2GKoQ4Mm7stovbuq1RmnSJy1Qx@HSK001IkeP4vTz7JT15s5mmcD70u8Orhq@H9Pv2Kdfs7pykeXLMk5tHjR@O7WKRhnaoa0OK/KyyVQOnluOJjslRWeeGpum5LJ2v2DYgDhA8BUJftuQBBV6wKzxXDcHe8if5wDKmwAKVo2AXAh2KKJWtSitflfQkLYGhCISIIJy0DugpnSFnzQjc9c4LWtFSbM5BE5SZULMPAmgrMKjJRQoKgivuuWkFeoMlZfAeC6S0Eu3MUR@CBjoKYdYY3TBjQdgYpWIVDZxYWjeoineFoS7q6Ai6CipxCDQ3aodOL3asKtEwWCcXAdK3GP8HUzcSyNRQDJcBL35DdN46Q9mv64WdDdPybZOt79e67zjIdrvXmfLrJ03L/g8 "Perl 5 – Try It Online")
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 49 bytes
Moved from the duplicate thread.
```
{S:g/(\w)(\w*)(\w)/{$0~$1.comb.pick(*).join~$2}/}
```
[Try it online!](https://tio.run/##HY2xDoIwFEV3v@KFEAOYgDo4QFzdnFxdHuUB1dI2bQkhBH69Fod7z3JuriYjbn6Yj@3dL6@yK5L3lIZke6XFEp@3@JIzNdS55uybZGn@UVxu8XUtVl8dLM7QJtFjlNAicyU8lXWgSWlBwFCCIWzAMoNDLaiBSZnGAloQSnY7XU/QchNGJxAYIMg5MsGRDehRMjei40oCGgIu/77hXR9OBDLKo7TyPw "Perl 6 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 19 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.γa}εDaićsD¨.rsθJ]J
```
[Try it online.](https://tio.run/##PZA9TgQxDIWv4o5mNXdAbLU1lBROxjuxlJ9V7GE0BTVXoUdI1Ih6rjQ4GYSUwvF7@eyXIuiY9n3YPvB1@zwj/7zJ@ft9qLJ9XZ4v@37vfakj5wm0AEIlIaw@UAVUeMDkKo8TwVPmF6rCup6AFcZCku8UEqqalTMswfxGspsGgkhNkKYgLNYHrHTqUslxBU63UhWzWqsNZ7ECtRuuXEUB8wgRrThQ4Aj@9MpTULhF9DTAY2uQ2Tzm7rEcihESiXTGWuauiXKMZsWxBVhYQ5mNUouLlBrHVrDjyOMs1AeFOdnDxEZpgSEXPQBkf7H@L2ZpVChewc3HgkdeaclDiTT8Ag)
**Explanation:**
```
.γ              # Consecutive group by:
  a             #  Is alphabetic (so all upper- and lowercase letters)
 }ε             # After the group-by, map each string to:
   D            #  Duplicate the current string
    ai          #  If it's alphabetic:
      ć         #   Extract head; pop and push the remainder-string and first character
                #   separated to the stack
                #    i.e. "According" → STACK: "ccording","A"
       s        #   Swap so remainder-string is at the top again
                #    STACK: "A","ccording"
        D       #   Duplicate it
                #    STACK: "A","ccording","ccording"
         ¨      #   Remove the last character from the copy
                #    STACK: "A","ccording","ccordin"
          .r    #   Shuffle the remaining characters
                #    STACK: "A","ccording","occdrni"
            s   #   Swap so the remainder-string is at the top again
                #    STACK: "A","occdrni","ccording"
             θ  #   Only leave its last character
                #    STACK: "A","occdrni","g"
              J #   Join the three back together to a string again
                #    STACK: "Aoccdrnig"
  ]             # Close both the if-statement and map
   J            # And join all strings in the list back together
                # (after which the result is output implicitly)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 13 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
r"%B%w+%B"Èö¬
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ciIlQiV3KyVCIsj2rA&input=IkFjY29yZGluZyB0byBhIHJlc2VhcmNoZXIgYXQgQ2FtYnJpZGdlIFVuaXZlcnNpdHksIGl0IGRvZXNuJ3QgbWF0dGVyIGluIHdoYXQgb3JkZXIgdGhlIGxldHRlcnMgaW4gYSB3b3JkIGFyZSwgdGhlIG9ubHkgaW1wb3J0YW50IHRoaW5nIGlzIHRoYXQgdGhlIGZpcnN0IGFuZCBsYXN0IGxldHRlciBiZSBhdCB0aGUgcmlnaHQgcGxhY2UuIFRoZSByZXN0IGNhbiBiZSBhIHRvdGFsIG1lc3MgYW5kIHlvdSBjYW4gc3RpbGwgcmVhZCBpdCB3aXRob3V0IHByb2JsZW0uIFRoaXMgaXMgYmVjYXVzZSB0aGUgaHVtYW4gbWluZCBkb2VzIG5vdCByZWFkIGV2ZXJ5IGxldHRlciBieSBpdHNlbGYgYnV0IHRoZSB3b3JkIGFzIGEgd2hvbGUuIg)
[Answer]
# [Go](https://go.dev), ~~248~~ 226 bytes
```
import(."math/rand";."regexp")
func f(s string)string{return MustCompile(`(\w)(\w+)(\w)`).ReplaceAllStringFunc(s,func(S string)(e string){k:=S[1:len(S)-1]
for _,i:=range Perm(len(k)){e+=k[i:i+1]}
return S[:1]+e+S[len(S)-1:]})}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=jZLPjtMwEMYFxzzFKBJaW-0G9YaCirRaiRtoReDUVqybTBpT_yn2hG6p9kn2UiHxUMuRJ2GcbPeMlMTOzPjn7_P44dfGnx4vdqreqg2CVdpl2u58oCJvLeXPP6Qt5r97ai_fPP4dg6LIraLudVCuyd8WecAN3u1ymbW9q6EVESIF7TZyHI4BqQ8OPvSRrr3daYPiViz3kt9J-shbWXzCnVE1XhlTDYveM0rEaSKK6swTeJ4dt-W8WsxKg05U8nK2ylof4OtUl3NWxYZuMFiRslspjziZbxe61JPZ6j57UlMtytlqgpNqcWaUq3t5Pzr98_LF4CUdi5BwzCrERnz0eyGLL07fCSmzqpzn1CF873W9hXXwewetv4Nvvd1hA_4HBkh5o34eoPGbPLth6dSK_FVcuvm7pUvj0uVTqKZ8alVizvOruvahYY9AHhQEjKhC3TFMEVwruw66YX-sgjeImg5T0MR8jO6CWDARl2oH-47rmXRWgSkRU0bBnuOgAk6HlHfmAGNnlSMOpc115ImioaDVIRJws9kLT0YUrBGe8kFvOoKhfwV8TgHkslq5oYZ9kDJgMcaBcfD9kIukjeFS1SQDe02d75kS_NqgTRyWwM8aa9VHHDbqessLrWZKMgzO0whAPovDszB2QxFNC-t-FDj6jcl55w0W_9OKp5twOo3jPw)
Embeds my [answer for "How to randomize letters in a word"](https://codegolf.stackexchange.com/a/257250/77309) within this answer.
* -22 from `rand.Perm`, string slices, and named return.
]