Sign in to follow this  
Followers 0
qwertylol

ifinstring

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

how do I find out how many items this array has ?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0