faustf Posted October 12, 2016 Share Posted October 12, 2016 hi guys i have array like this expandcollapse popupsku1 12.00 2.00 Taglia 32 32 Taglia coppa A Taglia torace S Fantasia A righe sku2 12.00 1.00 Taglia 34 34 Taglia coppa A AA Taglia torace S Colore principale Arancione Colore esatto Albicocca sku3 12.00 1.00 Taglia 36 36 AA S Materiale Lycra i want remove only number replicated how is possible do that ?? i tryed with _arrayunique , but remove also , duplicated word , exist an options??? thankz at all Link to comment Share on other sites More sharing options...
l3ill Posted October 12, 2016 Share Posted October 12, 2016 (edited) Arrayunique looks for anything doubled, tripled etc and deletes all but one instance. Is that not what you are attempting to do? turns out like this: Spoiler Row|Col 0 [0]|23 [1]|sku1 [2]|12.00 [3]|2.00 [4]|Taglia [5]|32 [6]|Taglia coppa [7]|A [8]|Taglia torace [9]|S [10]|Fantasia [11]|A righe [12]|sku2 [13]|1.00 [14]|34 [15]|AA [16]|Colore principale [17]|Arancione [18]|Colore esatto [19]|Albicocca [20]|sku3 [21]|36 [22]|Materiale [23]|Lycra Edited October 12, 2016 by l3ill added example My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Malkey Posted October 12, 2016 Share Posted October 12, 2016 I would remove only number replicates from an array this way. expandcollapse popup#include <Array.au3> ; ------- Create Array ---------- $a = StringRegExp(StringRegExpReplace(FileRead(@ScriptName), "(?s)^.*#cs\v+|\v+#ce.*$", ""), "\s*(.+)\s*", 3) _ArrayDisplay($a, "Original") ; ------- End of Create Array ---------- ; Remove only number duplicates from array. Local $sUniqueStr = "|" For $i = UBound($a) - 1 To 0 Step -1 If Not StringRegExp($a[$i], "[^\d.]") Then ; Check if the array element contains only digits, and maybe, a decimal point. If StringInStr($sUniqueStr, "|" & $a[$i] & "|") Then _ArrayDelete($a, $i) ; The number already exists in the $sUniqueStr string. Else $sUniqueStr &= $a[$i] & "|" ; Add only unique numbers to $sUniqueStr string. EndIf EndIf Next _ArrayDisplay($a, "Unique Numbers") #cs sku1 12.00 2.00 Taglia 32 32 Taglia coppa A Taglia torace S Fantasia A righe sku2 12.00 1.00 Taglia 34 34 Taglia coppa A AA Taglia torace S Colore principale Arancione Colore esatto Albicocca sku3 12.00 1.00 Taglia 36 36 AA S Materiale Lycra #ce faustf 1 Link to comment Share on other sites More sharing options...
faustf Posted October 12, 2016 Author Share Posted October 12, 2016 thankz so much is perfect Link to comment Share on other sites More sharing options...
czardas Posted October 13, 2016 Share Posted October 13, 2016 (edited) This solution is suitable for small arrays or arrays not containing many duplicates, but using _ArrayDelete() is slow. If you have a large array, you should be able to speed up the process using a function to separate the numbers first, and then use _ArrayUnique() on them. The two processes can also be integrated into a single optimized function by rewriting _ArrayUnique() in a way that forces it to ignore non-numeric entries, but that's slightly more complex. This last method will be faster and would also preserve the order of remaining entries. Edited October 13, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now