qwertylol Posted May 3, 2007 Share Posted May 3, 2007 I need to extrat from a string 002342342004234042342340 essentially what I am doing is to get the numbers between zeros, and then check if they match a string. how do I extract non-zero blocks into separate variable? Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 3, 2007 Share Posted May 3, 2007 Hi, #include<array.au3> $str = '002342342004234042342340' $matches = StringRegExp($str, '[^0]{1,}', 3) _ArrayDisplay($matches, 'found') So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
qwertylol Posted May 3, 2007 Author Share Posted May 3, 2007 how do I find out how many items this array has ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 3, 2007 Share Posted May 3, 2007 how do I find out how many items this array has ? Might be easier to use StringSplit(). It will return an array and the count is in $avArray[0]: #include <array.au3> $Input = "002342342004234042342340" Do $Input = StringReplace($Input, "00", "0") Until Not @extended $avArray = StringSplit($Input, "0") _ArrayDisplay($avArray, "Results") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 4, 2007 Share Posted May 4, 2007 Hi, or something like: #include<array.au3> $str = '002342342004234042342340' $matches = StringRegExp($str, '[^0]+', 3) _ArrayInsert($matches, 0, UBound($matches) + 1) _ArrayDisplay($matches, 'found') So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 4, 2007 Share Posted May 4, 2007 #include<array.au3> $str = '002342342004234042342340' $matches = StringRegExp($str, '[^0]+', 3) _ArrayInsert($matches, 0, UBound($matches) + 1) _ArrayDisplay($matches, 'found') Nice and tight. But don't you want the added value to be just UBound($matches), without the +1? Arrays with item counts in element 0 are usually $avArray[0] = Ubound($avArray) - 1 But since you are adding one element, it becomes just Ubound($avArray), I think... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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