mIRC Home    About    Download    Register    News    Help

Print Thread
$duplicate snippet , make for me pls #107039 06/01/05 10:05 AM
Joined: Dec 2004
Posts: 13
S
ScottK Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 13
hie
can someone make me a simple snippet for $duplicate

example i want is like $duplicate(%a,b)

%a = text1 text2 text3
%b = %text3 %text4 %text5
%c is the duplicate values in %a & %b example
%c = %text3
%d is the return of the values from both %a & %b without duplicate values , example %text1 %text2 %text3 %text4 %text5

thx for reading and happy coding

Re: $duplicate snippet , make for me pls #107040 06/01/05 10:25 AM
Joined: Aug 2003
Posts: 314
S
Sigh Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
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

Re: $duplicate snippet , make for me pls #107041 06/01/05 11:13 AM
Joined: Dec 2004
Posts: 13
S
ScottK Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 13
hye sigh
thx for your work
but , there is something missing there (for me)

//echo -a $duplicate(text1 text2 text3,text3 text4 text5)
will return to text3 text4 text5 text1 text2
how to make the result will be like this
text3 text4 text5 text1 text2 %text3

Re: $duplicate snippet , make for me pls #107042 06/01/05 09:43 PM
Joined: Dec 2004
Posts: 13
S
ScottK Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 13
nevermind , %d + %e = the result i want
thx so much sigh laugh