Sign in to follow this  
Followers 0
lolp1

Need string trim help

8 posts in this topic

Hello,

Well I fairly understand string trim, but I don't understand how it can be put into use for non static text..

For example "input" I have is this:

[07:15] Europe: [15:18:01] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-139.
[07:18] Europe: [15:20:48] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-140.
[07:22] Europe: [15:24:22] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.
[07:24] Europe: [15:26:25] <From Vic(Bot)> Your friend Vic(Bot) has exited Battle.net.

It will always have different time stamps, and different game name at the end, but I would like my output like:

Europe:Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.

How could I do this?

For to be more clear:

Input =

Europe: [15:24:22] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.

What out put I would want:

Europe:Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.

Keep in mind the game name, and time stamps are always different..

Share this post


Link to post
Share on other sites



Use StrinRegExpReplace()

But with pattern I can't help you, I'm regexp newbie :)

Not sure, what this is for... :E

Share this post


Link to post
Share on other sites

Then look into Autoit Helpfile.

I did, the func does not exsist.. or at least auto it doesn't want to be nice and find it. I'm fairly sure Stringtrim is still the way to go..

Share this post


Link to post
Share on other sites

Still, does not help me figure out my problem on how to deal with non-static text..

Share this post


Link to post
Share on other sites

For to be more clear:

Input =

Europe: [15:24:22] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.

What out put I would want:

Europe:Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141.

Here's a solution that doesn't use RegExp, just looking for the constant reappearing characters as markers for regular String functions (StringLeft, StringTrimLeft, and StringReplace)

;what we have
$string = "Europe: [15:24:22] <From Vic(Bot)> Your friend Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141."

;what we want
$desired = "Europe:Vic(Bot) entered a Diablo II Lord of Destruction game called Talibaal-141."

; Find the first instance of ":" in the string
;the trailing "1" option finds first instance only
$FindFirstColon = StringInStr($string,":",0,1)

; take the characters up to & including the colon as the first part of output
$outPut = StringLeft($String,$FindFirstColon)

;Find the first ">" in the the string
$findEndFrom = StringInStr($string,">",0,1)

;get rid of everything at the beginning of the string up to & incl. the ">"
$String = StringTrimLeft($String,$FindEndFrom)

;strip " Your friend " out from remaining string
$String = StringReplace($string," Your friend ","",1,0)

;join the two pieces of our output together
$Output &= $String

MsgBox(4096,""," Output = " & $OutPut & @CRLF & "Desired = " & $Desired)

Hopefully you won;t just cut and paste but will study what was done here so you can learn from it.

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