cookiemonster Posted January 15, 2015 Share Posted January 15, 2015 I have an array, and I want to remove all lines that contain '.png' in it, each line in the array contains something like 'C:folderfolderdog.png', so I need to be left only with only lines that do not contain .png Can someone point me in the direction of how to do this to the array? Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted January 15, 2015 Share Posted January 15, 2015 (edited) Best thing to do is check how your array is populated and avoid putting the data in it. Checkout stringregexp in a "for loop". It is in the help file. For the array you can use _ArrayDelete Edited January 15, 2015 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Valuater Posted January 15, 2015 Share Posted January 15, 2015 (edited) For $i = 1 to $array[0] -1 if stringinstr($array[$i], "png") then Arraydelete($array, $array[$i]) next ... written on screen not checked 8) Edited January 15, 2015 by Valuater Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2015 Share Posted January 15, 2015 Best thing to do is check how your array is populated and avoid putting the data in it. Checkout stringregexp in a "for loop". It is in the help file. For the array you can use _ArrayDelete Agreed, but I imagine StringInStr will be quicker, or even StringRight. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mikell Posted January 15, 2015 Share Posted January 15, 2015 Assuming the elements count is in $array[0] For $i = $array[0] to 1 step -1 If StringRight($array[$i], 4) = ".png" Then Arraydelete($array, $i) Next Loop backwards Link to comment Share on other sites More sharing options...
jguinch Posted January 15, 2015 Share Posted January 15, 2015 This one should be faster, with only one redim : Local $aList[10] = ["file1.txt", "file2.pdf", "file3.png", "file4.jpg", "file5.doc", "file6.png", "file7.rtf", "file8.png", "file9.zip", "file10.xlsx"] Local $iIndex = 0 For $i = 0 To UBound($aList) - 1 If StringRight($aList[$i], 4) <> ".png" Then $aList[$iIndex] = $aList[$i] $iIndex += 1 EndIf Next Redim $aList[$iIndex] Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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