Sign in to follow this  
Followers 0
gazkin

Split string

5 posts in this topic

Hi Guys,

I want to split a sentence in a array that contains all words used in the sentence.

If I use this script

$text = StringReplace("this is a line of text", " ", " ")

MsgBox(0, "New string is", $text[1])

It tells me that $text doesnt contain an array.

How to handle this?

Share this post


Link to post
Share on other sites



StringReplace returns a new string according to the help file.

I guess you need:

#Include <String.au3>

$text = _StringSplit("this is a line of text", " ")


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

StringReplace returns a new string according to the help file.

I guess you need:

#Include <String.au3>

$text = _StringSplit("this is a line of text", " ")

Just use the built in function StringSplit, _StringSplit is obsolete and will be gone from the next version.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

You could also use StringRegExp()

#include <array.au3>

$String = "How long is a piece of string?"
$aString = StringRegExp($String, "\w+\S", 3)

_ArrayDisplay($aString, "$aString")

Cheers

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