Further golfing this C# code from Scramble words while preserving their outlines I'll start off by saying I checked and checked again that this question should be on topic.

I will also clearly state that this is a tips question about further golfing a certain set of code not a challenge.



I recently answered the following challenge:  Scramble words while preserving their outlines:


  It is well known that a text can still be read while the innards of its words have been scrambled, as long as their first and last letters plus their overall outlines remain constant. Given a printable Ascii+Newline text, scramble each word according to these rules:
  
  
  Scrambling must be (pseudo) random.
  A word is a sequence of the Latin characters, A through Z.
  Only initial letters will ever be uppercase.
  The first and last letters must stay untouched.
  When scrambling, only letters within one of the following groups may exchange places:
  
  
  acemnorsuvwxz
  bdfhkl
  gpqy
  it
  j (stays in place)
  
  


My answer is in C# and coming in, currently, at 394 bytes:

namespace System{using Text.RegularExpressions;using Linq;s=&gt;Regex.Replace(s,@"[A-Za-z](([acemnorsu-xz])|([bdfhkl])|([gpqy])|([it]))*?[a-z]?\b",m=&gt;{var a=m.Value.ToCharArray();for(int i=1,j;++i&lt;6;){var c=m.Groups[i].Captures;var n=c.Cast&lt;Capture&gt;().Select(p=&gt;p.Index-m.Index).ToList();foreach(Capture p in c){a[j=n[new Random().Next(n.Count)]]=p.Value[0];n.Remove(j);}}return new string(a);});}


I think there's room for golfing in the Linq statement and foreach loop at least.

Can this code be further golfed down?
As I am using linq in my program, I can change ToCharArray to ToArray to save 4 bytes.

I can also change the namespace around to be either System.Linq or System.Text.RegularExpressions to save a further 6 bytes by removing the using for it:

namespace System.Text.RegularExpressions


As @MartinEnder♦︎ points out in the comments I can save 10 bytes by re-ordering the groups in the regex and changing [A-Za-z] to \p{L}:

\p{L}(([gpqy])|(i|t)|(j)|([bdf-l])|([a-z]))*?[a-z]?\b