This is a simple example, it doesn't consider repeated tokens, just attempts to match each word from the first parameter to another in the second parameter:

Code:
alias duplicate {
  var %a = $1,%b = $2,%c,%d,%e
  while ($regsub(%b,([^ ]+),,%b)) {
    %e = $regml(1)
    if ($regsub(%a,$+((^| )\Q,$replacecs(%e,\E,\E\\E\Q),\E(?= |$)),,%a)) %c = %c %e
    else %d = %d %e
  }
  %d = %d %a

  ; Commands here with %c and %d
  return %c $cr %d
} 


$duplicate(a,b)

%c is then filled with the words common to both strings, %d would consist of those uncommon to both