Jump to content

Cutting unneeded data off a string


Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...