RaenGar Posted July 10, 2007 Posted July 10, 2007 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?
someone Posted July 10, 2007 Posted July 10, 2007 (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 July 10, 2007 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd
BrettF Posted July 10, 2007 Posted July 10, 2007 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) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now