Sign in to follow this  
Followers 0
Koerveter

Turning a string into an array!

9 posts in this topic

Is there anyway to turn a string into an array with 2characters in each arraydimension?

Please help :)

Thanks in advance!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$stringLen = StringLen($String)
dim $arry[$stringLen + 1]

for $s = 1 to $stringLen step 2
     $array[$s] = StringMid($string, $s, 2)
next

I didnt test it but thats the basic idea

unless i had an epic brain fart and was totally wrong

Edited by narayanjr

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include<Array.au3>
$string = "aabbccddeeffg"
$re = StringRegExp($string, '(?U).{2}|.', 3)
_ArrayDisplay($re)

Edited by weaponx

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$stringLen = StringLen($String)
dim $arry[$stringLen + 1]

for $s = 1 to $stringLen step 2
     $array[$s] = StringMid($string, $s, 2)
nextoÝ÷ Ù8Zµ©f¢Ëp¢¹w}Ó«®ì=«­¢+Ù¥´ÀÌØíÉÉålÀÌØíÍÑÉ¥¹1¸¬Åt(ÀÌØí¬ôÀ)½ÈÀÌØíÌôÄѼÀÌØíÍÑÉ¥¹1¸ÍÑÀÈ(ÀÌØíÉÉålÀÌØí­tôMÑÉ¥¹5¥ ÀÌØíÍÑÉ¥¹°ÀÌØḭ́Ȥ(ÀÌØí¬ô¬Ä)¹á

That code will work! Thanks again! :)

Edited by Koerveter

Share this post


Link to post
Share on other sites

Did you look at the code I posted? Its one line to create the array this way.

Share this post


Link to post
Share on other sites

Did you look at the code I posted? Its one line to create the array this way.

Yeah, just tried it out, works like a charm! BIG THANKS TO YOU! ;D

Share this post


Link to post
Share on other sites

yeah weaponx's way is alot better ive never really used StringRegExp so i just told you the way i knew

i am probably gonna look into it now im gonna need something like that soon i think

Share this post


Link to post
Share on other sites

StringRegExp($string, '(?U).{2}|.', 3)
StringRegExp($string, '.{1,2}', 3)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

The winner takes it all :)

#include<Array.au3>
Global $string = "123456789"
Global $re = StringRegExp($string, '..|.', 3)
_ArrayDisplay($re)

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

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