Sign in to follow this  
Followers 0
Wb-FreeKill

Split sentence in pieces

4 posts in this topic

How can i split a sentence in pieces, like:

"I am an idiot"

split into

$string1 = "I"

$string2 = " "

$string3 = "a"

$string4 = "m"

$string5 = " "

ect

so i can take out each letter

Share this post


Link to post
Share on other sites



How can i split a sentence in pieces, like:

"I am an idiot"

split into

$string1 = "I"

$string2 = " "

$string3 = "a"

$string4 = "m"

$string5 = " "

ect

so i can take out each letter

<{POST_SNAPBACK}>

.... straight from help.........

$result = StringLeft("I am a string", 3)

MsgBox(0, "Leftmost 3 characters are:", $result)

....but you knew that


NEWHeader1.png

Share this post


Link to post
Share on other sites

Array vs variables.. you choose.

; Method #1 : Using variables
; ===========================

Dim $string = "Wb-FreeKill is an idiot !", $msgText = "$string<num>" & @CRLF

For $i = 1 To StringLen($string)
    Assign("string" & $i,StringMid($string,$i,1))
    $msgText = $msgText & @CRLF & $i & " : " & StringMid($string,$i,1)
Next

MsgBox(64,"Variables",$msgText)


; Method #2 : Using an array
; ===========================

Dim $string = "Wb-FreeKill is an idiot !", $msgText = "$array[<num>]" & @CRLF
$array = StringSplit($string,"")

For $i = 1 To StringLen($string)
    $msgText = $msgText & @CRLF & $i & " : " & $array[$i]
Next

MsgBox(64,"Array",$msgText)

Share this post


Link to post
Share on other sites

You guy's help are really much appriciated, i tried, i look trough the helpfile, and would rater make a quick question here instead of trieng for a long time... but it's more simple than i tought.. so stop making me look like an idiot...

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