Sign in to follow this  
Followers 0
RaenGar

Cutting unneeded data off a string

3 posts in this topic

Lets say I have a string

10:33 RaenGar: Please help!

I want to save it from a chat window to a txt. But i only need the "Raengar: Please help!" part

10:33 can be 0:00, so the length of unneeded data varies - how do I delete it - preferrably before writing to the .txt?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think of 2 ways.... use stringsplit, and split the line of text at each space. you know what you want to keep is after the first space...

OR

you could do a stringinstr and seach for the first space. StringinStr will return the position of the space so use stringinstr and then stringtrimleft and remove what stringinstr has returned.

Sorry I don't have time to code up an example, but either should work for you. The second may might be easier actually.

EDIT: Oh the things insomnia will do to you... since I see bert gave you an example of option 1 heres option 2...

$Text = "10:33 RaenGar: Please help!"
$Position = StringInStr($Text, " ")
MsgBox(0, "trimmed text", StringTrimLeft($Text, $Position))

$Text = "0:00 RaenGar: Please help!"
$Position = StringInStr($Text, " ")
MsgBox(0, "trimmed text 2", StringTrimLeft($Text, $Position))
Edited by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

Like...

$string1 = "10:33 RaenGar: Please help!"
$string2 = "0:33 RaenGar: Please help!"

$split = StringSplit ($string1, ":")
$string = "String 1 (10:33 RaenGar: Please help!)" &StringTrimLeft ($split[2], 2) &":"& $split[3] & @CRLF
$split = StringSplit ($string2, ":")
$string &= "String 2 (0:33 RaenGar: Please help!)" &StringTrimLeft ($split[2], 2) &":"& $split[3] & @CRLF
MsgBox (0, "", $string)

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