Deye Posted February 27, 2020 Share Posted February 27, 2020 What do you suspect is the limitation here that wont include : get the "1" 's in to the output ? Local $s = '' _ & '3,5,2,10,2,3,1,9,6,8,0,3,1,3,1,5,9,9,3,10,8,6,7,9,2,2,0,2,3,4,10,3,9,9,9,10,2,1,1,9,8,1,9,2,9,4,6,0,' _ & '6,3,8,7,10,9,6,8,6,2,9,8,8,3,0,1,5,5,10,8,3,4,0,4,2,3,7,9,1,7,2,1,5,1,4,2,1,2,7,7,10,10,2,5,2,2,10,6' _ & ',6,0,2,10,4,7,6,9,3,9,9,5,3,1,2,8,10,5,2,9,4,8,6,2,0,1,3,7,7,9,5,4,6,7,0,6,3,9,9,9,7,2,2,2,8,5,4,4,2' _ & ',2,6,9,7,6,2,8,5,2,8,5,10,9,0,5,1,7,10,9,9,8,1,10,3,10,4,3,6,4,3,0,8,6,5,7,4,1,5,4,8,1,0,4,2,10,1,10' _ & ',3,3,7,10,8,2,1,8,2,3,8,4,5,0,9,6,7,3,1,0,6,3,8,10,3,2,7,8,8,7,8,5,10,2,7,2,1,10,0,10,4,6,7,3,4,4,2,' _ & '6,1,3,0,5,0,8,5,4,7,8,0,7,6,2,2,5,8,4,2,6,1,1,10,0,4,5,0,2,0,6,4,1,6,0,4,9,1,10,1,0,7,0,10,8,6,7,1,2' _ & ',5,7,5,2,2,2,7,2,2,7,6,7,3,3,4,5,2,7,2,0,6,9,7,9,8,6,5,4,6,6,0,3,0,4,9,0,5,9,2,5,2,4,6,2,6,10,10,0,9' _ & ',2,8,3,1,2,3,3,3,10,6,3,8,0,9,8,7,4,4,10,2,6,2,3,5,7,6,8,1,3,10,2,6,7,6,4,3,1,5,2,2,0,1,7,7,10,9,1,4' _ & ',5,1,9,7,6,2,5,6,1,10,4,10,7,1,0,4,1,5,10,3,4,1,1,3,9,0,4,10,9,4,6,4,2,0,1,10,0,6,6,2,5,10,6,1,1,9,7' _ & ',9,8,2,2,6,6,2,5,5,3,10,2,4,3,3,5,8,3,5,2,4,4,10,5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,7,7,3,6,7,5,6,10,2,2,8,8,1,6,6,3,9,' _ & '4,2,9,9,10,4,8,0,4,2,1,2,5,9,3,9,0,8,8,10,0,7,1,5,4,9,7,9,7,1,10,4,6,4,3,7,9,10,8,8,10,' $sOutput = StringUnique_Delim($s, ",") MsgBox('', '', $sOutput) Func StringUnique_Delim($sString = "", $delim = ",") $delim = "\" & $delim Return StringTrimLeft(StringRegExpReplace($delim & $sString, '(\H[^' & $delim & ']++)(?=.*\1)|' & $delim & '(?=' & $delim & ')|(' & $delim & '$)', ""), 2) ;~ Return StringTrimLeft(StringRegExpReplace($delim & $sString, '(\H[^,]++)(?=.*\1)|,(?=,)|(,$)', ""), 1) EndFunc ;==>StringUnique_Delim Link to comment Share on other sites More sharing options...
Nine Posted February 27, 2020 Share Posted February 27, 2020 Try this : $sOutput = StringUnique_Delim($s, ",") MsgBox('', '', $sOutput) Func StringUnique_Delim($sString = "", $delim = ",") Return StringTrimLeft(StringRegExpReplace($delim & $sString, '(,+\b\d+\b)(?=.*?\b\1\b)|,{2}|,$', ""),1) EndFunc ;==>StringUnique_Delim Deye 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Deye Posted February 27, 2020 Author Share Posted February 27, 2020 (edited) good it seems that the one you put is faster Try it with this modified string now : still wont get the one's: Spoiler Local $s = '' _ & '2,9,6,7,4,3,5,5,4,5,8,10,8,4,5,2,5,9,4,2,7,3,1,0,6,2,10,7,7,2,5,6,0,7,6,9,10,5,8,10,0,10,10,6,0,8,4,' _ & '0,9,2,3,9,8,7,0,10,0,10,10,4,3,6,3,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9,9,6,4,2,2,10,6,1,6,4,3,5,6,2,10,0,6,3' _ & ',8,8,5,0,7,4,9,9,2,5,7,7,7,10,9,4,10,8,9,6,4,10,8,0,5,4,9,5,10,1,0,7,1,4,7,6,3,6,1,2,10,5,3,5,8,1,8,' _ & '10,1,5,8,6,7,0,4,6,6,9,4,10,5,3,1,9,3,10,9,1,2,4,0,9,10,0,0,9,4,8,2,5,3,0,2,5,3,0,9,10,3,1,1,0,7,1,6' _ & ',6,9,7,10,2,2,2,9,1,3,7,6,5,9,9,6,2,3,0,6,9,1,3,3,4,7,5,3,6,2,1,3,10,1,4,0,10,1,6,0,8,3,1,9,9,10,5,4' _ & ',1,10,8,5,7,9,8,2,1,10,3,3,0,7,6,4,5,10,10,9,9,4,8,10,10,6,6,5,7,1,9,3,5,9,9,8,4,5,4,0,10,6,7,7,6,10' _ & ',3,6,0,4,5,5,8,2,0,6,4,1,2,1,5,10,3,8,8,2,8,8,2,0,0,9,8,0,6,8,10,4,0,10,1,7,6,10,9,4,10,7,2,7,1,5,6,' _ & '3,6,9,3,9,10,7,2,7,4,3,4,0,10,8,6,3,6,3,1,4,9,0,9,7,7,10,0,1,5,1,1,3,4,0,9,6,8,4,8,4,7,3,6,6,6,7,3,0' _ & ',1,3,5,0,6,0,4,1,0,10,7,5,9,9,7,2,2,8,10,7,1,2,7,6,5,3,4,4,6,7,5,10,4,6,10,1,6,2,9,10,1,3,10,6,10,2,' _ & '8,10,0,5,1,4,8,8,8,9,7,0,9,0,6,5,8,2,6,3,10,10,4,1,8,0,0,3,4,3,1,2,5,2,8,9,9,5,2,5,3,9,5,10,1,3,0,4,' _ & '6,2,10,7,7,5,10,2,10,0,9,1,1,9,7,2,1,0,4,6,3,3,9,10,5,3,7,4,8,10,8,7,6,0,3,0,0,0,0,0,4,7,9,5,3,7,10,' _ & '2,6,8,8,4,' Edit : it seems like it works my bad used the output from the first function with the next .. Edited February 27, 2020 by Deye Link to comment Share on other sites More sharing options...
Nine Posted February 27, 2020 Share Posted February 27, 2020 Working for me, got the 1 with your new input string... Deye 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Deye Posted February 27, 2020 Author Share Posted February 27, 2020 (edited) Won't do for this string: Spoiler Local $s = '' _ & ',88.7981257636566,,,,,16.6675195184071,,,,,4.79034703341313,,,,,39.9053441327997,,,,,66.694657111307' _ & '6,,,,,39.9053441327997,,,,,37.1229492216371,,,,,22.0662507547531,,,,,39.9053441327997,,,,,54.76093110' _ & '83797,,,,,92.2840119639877,,,,,39.9053441327997,,,,,39.9053441327997,,,,,8.78667356004007,,,,,5.9906' _ & '0935317539,,,,,39.9053441327997,,,,,39.9053441327997,,,,,93.1673846032936,,,,,39.9053441327997,,,,,80' _ & '.5179890429135,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,' _ & ',,,39.9053441327997,,,,,39.6048657577485,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997' _ & '225,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,81.57234' _ & '70482044,,,,,39.9053441327997,,,,,95.5796377549414,,,,,39.9053441327997,,,,,97.2679230114445,,,,,21.' _ & '4295158467721,,,,,39.9053441327997,,,,,39.9053441327997,,,,,83.6249360623769,,,,,97.4564977802802,,,' _ & ',,63.3761930796318,,,,,84.6940687603783,,,,,5.26956521882676,,,,,12.9516193692107,,,,,1.241976858815' _ & '18,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,51.7095433811191,,,,,52.1870405' _ & '438822,,,,,33.2605571614113,,,,,39.9053441327997,,,,,72.9274834136013,,,,,12.6099660850596,,,,,86.29' _ & '04209026601,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,' _ & '57.3252596291713,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.413879588712,,,,,26.2016438592691,' _ & ',,,,39.9053441327997,,,,,39.9053441327997,,,,,78.5442069799174,,,,,39.9053441327997,,,,,94.475865373' _ & '1551,,,,,39.9053441327997,,,,,39.9053441327997,,,,,89.25552565814,,,,,39.9053441327997,,,,,16.082517' _ & '5868813,,,,,39.9053441327997,,,,,39.9053441327997,,,,,57.9336796300486,,,,,39.9053441327997,,,,,64.7' _ & '39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,1.86551364092156,,,,,39.9053441327997,,,,' _ & ',39.9796285820194,,,,,39.9053441327997,,,,,39.9053441327997,,,,,99.5431522277649,,,,,39.9053441327997' _ & '9,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,44.3370242500678,,,,,39.9053441327997' _ & '55959,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,19.2053513345309,,,,,18.840' _ & '8538626973,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,11.' _ & '39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,' _ & ',,27.9824080825783,,,,,39.9053441327997,,,,,18.0377603929956,,,,,39.9053441327997,,,,,39.9053441327997' _ & '54,,,,,52.7667207757477,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,91.3669707' _ & '472436,,,,,94.4973681063857,,,,,39.9053441327997,,,,,49.631222307682,,,,,39.9053441327997,,,,,15.866' _ & '39.9053441327997,,,,,9.15716084255837,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,2' _ & '39.9053441327997,,,,,61.0236024153419,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,' _ & ',,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997' _ & '039,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,23.4713064718526' _ & '69726,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,40.5146' _ & '999040153,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,40' Edited February 27, 2020 by Deye Link to comment Share on other sites More sharing options...
Deye Posted February 27, 2020 Author Share Posted February 27, 2020 (edited) Resolved to this which will get the ones now but still not as fast i hoped .. Func StringUnique_Delim($sString = "", $sDelim = ",") $sDelim = "\" & $sDelim Return StringTrimLeft(StringRegExpReplace($sDelim & $sString, '(' & $sDelim & '[^' & $sDelim & ']++)(?=.*\1' & $sDelim & ')|' & $sDelim & '(?=' & $sDelim & ')|(' & $sDelim & '$)', ""), 2) EndFunc ;==>StringUnique_Delim Thanks Edited February 27, 2020 by Deye Link to comment Share on other sites More sharing options...
Nine Posted February 27, 2020 Share Posted February 27, 2020 (edited) Looks like this one works for all cases and is quite fast : Func StringUnique_Delim($sString = "", $delim = ",") Return StringRegExpReplace(StringRegExpReplace($delim & $sString, '(,[^,]++)(?=.*?\1,)', ""),"(^,+|,+$)|,+(?=,)", "") EndFunc ;==>StringUnique_Delim Edited February 27, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Deye Posted February 27, 2020 Author Share Posted February 27, 2020 yes, opting to use ".*?\1" instead of ".*\1" will speed my above example just the same Link to comment Share on other sites More sharing options...
Malkey Posted February 28, 2020 Share Posted February 28, 2020 Another example. expandcollapse popup#Include <Array.au3> Local $s = '88.7981257636566,,,,,16.6675195184071,,,,,4.79034703341313,,,,,39.9053441327997,,,,,66.694657111307' _ & '6,,,,,39.9053441327997,,,,,37.1229492216371,,,,,22.0662507547531,,,,,39.9053441327997,,,,,54.76093110' _ & '83797,,,,,92.2840119639877,,,,,39.9053441327997,,,,,39.9053441327997,,,,,8.78667356004007,,,,,5.9906' _ & '0935317539,,,,,39.9053441327997,,,,,39.9053441327997,,,,,93.1673846032936,,,,,39.9053441327997,,,,,80' _ & '.5179890429135,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,' _ & ',,,39.9053441327997,,,,,39.6048657577485,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997' _ & '225,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,81.57234' _ & '70482044,,,,,39.9053441327997,,,,,95.5796377549414,,,,,39.9053441327997,,,,,97.2679230114445,,,,,21.' _ & '4295158467721,,,,,39.9053441327997,,,,,39.9053441327997,,,,,83.6249360623769,,,,,97.4564977802802,,,' _ & ',,63.3761930796318,,,,,84.6940687603783,,,,,5.26956521882676,,,,,12.9516193692107,,,,,1.241976858815' _ & '18,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,51.7095433811191,,,,,52.1870405' _ & '438822,,,,,33.2605571614113,,,,,39.9053441327997,,,,,72.9274834136013,,,,,12.6099660850596,,,,,86.29' _ & '04209026601,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,' _ & '57.3252596291713,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.413879588712,,,,,26.2016438592691,' _ & ',,,,39.9053441327997,,,,,39.9053441327997,,,,,78.5442069799174,,,,,39.9053441327997,,,,,94.475865373' _ & '1551,,,,,39.9053441327997,,,,,39.9053441327997,,,,,89.25552565814,,,,,39.9053441327997,,,,,16.082517' _ & '5868813,,,,,39.9053441327997,,,,,39.9053441327997,,,,,57.9336796300486,,,,,39.9053441327997,,,,,64.7' _ & '39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,1.86551364092156,,,,,39.9053441327997,,,,' _ & ',39.9796285820194,,,,,39.9053441327997,,,,,39.9053441327997,,,,,99.5431522277649,,,,,39.9053441327997' _ & '9,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,44.3370242500678,,,,,39.9053441327997' _ & '55959,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,19.2053513345309,,,,,18.840' _ & '8538626973,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,11.' _ & '39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,' _ & ',,27.9824080825783,,,,,39.9053441327997,,,,,18.0377603929956,,,,,39.9053441327997,,,,,39.9053441327997' _ & '54,,,,,52.7667207757477,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,91.3669707' _ & '472436,,,,,94.4973681063857,,,,,39.9053441327997,,,,,49.631222307682,,,,,39.9053441327997,,,,,15.866' _ & '39.9053441327997,,,,,9.15716084255837,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,2' _ & '39.9053441327997,,,,,61.0236024153419,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,' _ & ',,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997' _ & '039,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,23.4713064718526' _ & '69726,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,40.5146' _ & '999040153,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,39.9053441327997,,,,,40' Local $sOutput = StringUnique_Delim($s, ",") ConsoleWrite($sOutput & @CRLF) ; Display results in array Local $d[0] _ArrayAdd($d, $sOutput, 0, ",") _ArrayDisplay($d) Func StringUnique_Delim($sString = "", $delim = ",") $delim = "\" & $delim ;Return StringRegExpReplace($s, "(?m)((?<=^|,)[^,]+(?=,)),*(?=.*?,?\1,?)|(^,+|,+$)|,+(?=,)", "") Return StringRegExpReplace($s, "(?m)((?<=^|" & $delim & ")[^" & $delim & "]+(?=" & $delim & "))" & $delim & "*(?=.*?" & $delim & "?\1" & $delim & "?)|(^" & $delim & "+|" & $delim & "+$)|" & $delim & "+(?=" & $delim & ")", "") ;Return StringRegExpReplace(StringRegExpReplace($delim & $sString, '(,[^,]++)(?=.*?\1,)', ""), "(^,+|,+$)|,+(?=,)", "") EndFunc ;==>StringUnique_Delim Link to comment Share on other sites More sharing options...
Deye Posted February 28, 2020 Author Share Posted February 28, 2020 (edited) just happy it got 9 times faster than the Scripting.Dictionary method for longer strings .. Func StringUnique_Delim($sString = "", $sDelim = ",") $sDelim = "\" & $sDelim Return StringTrimLeft(StringRegExpReplace($sDelim & $sString, '(' & $sDelim & '[^' & $sDelim & ']++)(?=.*?\1' & $sDelim & ')|' & $sDelim & '(?=' & $sDelim & ')|(' & $sDelim & '$)', ""), StringLen($sDelim)) EndFunc ;==>StringUnique_Delim Malkey, your example will miss out "0" from this string: $s = '' _ & '7,8,1,3,7,9,1,3,4,9,0,9,5,0,0,7,3,1,7,5,2,10,10,8,0,9,8,8,5,5,1,10,0,4,1,1,4,0,9,2,10,7,5,4,7,8,4,8,' _ & '5,10,7,4,5,9,3,8,9,8,9,10,5,8,7,2,9,0,9,1,7,6,8,4,3,5,4,5,6,0,10,10,7,8,4,9,1,6,7,2,3,0,3,3,0,10,10,' _ & '3,1,1,8,4,' Edited February 28, 2020 by Deye 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