Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output non-duplicate strings after removing duplicate strings?
#1
I proceeded as follows, but I can not completely remove duplicate strings.

How do I remove duplicate text in an unaligned string?

Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
#region ...
str s= 
;23052389
;22584935
;23055690
;22878849
;22628765
;22234902
;23048968
;23046547
;22584932
;23018146
;19625264
;22584920
;23045882
;22906797
;23053239
;22584918
;23037988
;23052389
;22584935
;23055690
;22878849
;22628765
;22234902
;23048968
;23046547
;22584932
;23018146
;19625264
;22584920
;23045882
;22906797
;23053239
;22584918
;23037988
;23052389
;22584935
;23055690
;22878849
;22628765
;22234902
;23048968
;23046547
;22584932
;23018146
;19625264
;22584920
;23045882
;22906797
;23053239
;22584918
;23037988
;23052389
;22584935
;23055690
;22878849
;22628765
;22234902
;23048968
;23046547
;22584932
;23018146
;19625264
;22584920
;23045882
;22906797
;23053239
;22584918
;23037988
;23052389
;22584935
;23055690
;22878849
;22628765
;22234902
;23048968
;23046547
;22584932
;23018146
;19625264
;22584920
;23045882
;22906797
;23053239
;22584918
;23037988
#endregion

ARRAY(str) a
str record
foreach _s s
,a[]=_s

foreach _s s
,str Get; int cc
,if(!findrx(_s "(\d+)" 0 4 Get 1)) out "ERROR"; ret
,int i found=0
,for i 0 a.len
,,
,,if (find(a[i] Get 0 1) != -1)
,,,if found
,,,,out a[i]
,,,,a.remove(i)
,,,,out
,,,,break
,,,else
,,,,found=1
,,str output=a[i]
,,out output
#2
Function ARRAY_str_RemoveDuplicates
Code:
Copy      Help
;/
function ARRAY(str)&a

int i j
for i a.len-1 -1 -1
,str& s=a[i]
,for j 0 i
,,if a[j]=s
,,,a.remove(i)
,,,break

test
Macro Macro358
Code:
Copy      Help
str s=
;123
;456
;789
;789
;123
;456
;456
;123
;789

ARRAY(str) a=s
ARRAY_str_RemoveDuplicates a
out a
#3
Thank you so much!
simple is perfect!!


Forum Jump:


Users browsing this thread: 1 Guest(s)