d0n Posted June 18, 2009 Share Posted June 18, 2009 Basically what i want to do is get the Text between the brackets, this code does the trick but i was wondering if there is a better way to do it? $Title = WinGetTitle("Game (") $1 = Stringinstr($Title,"(") $2 = Stringinstr($Title,")") $3 = StringLen($Title) $Title = StringTrimLeft($Title, $1) $Title = StringTrimRight($Title, $3-$2+1) MsgBox("","",$Title) Link to comment Share on other sites More sharing options...
Malkey Posted June 18, 2009 Share Posted June 18, 2009 Basically what i want to do is get the Text between the brackets, this code does the trick but i was wondering if there is a better way to do it? $Title = WinGetTitle("Game (") $1 = Stringinstr($Title,"(") $2 = Stringinstr($Title,")") $3 = StringLen($Title) $Title = StringTrimLeft($Title, $1) $Title = StringTrimRight($Title, $3-$2+1) MsgBox("","",$Title)If this works, it could be considered a better way by the minimumalists. ; $Title = WinGetTitle("Game (") $Title = StringRegExpReplace ($Title,"(.*)\((.*)\)(.*)","\2") MsgBox("","",$Title) ; Link to comment Share on other sites More sharing options...
Briegel Posted June 18, 2009 Share Posted June 18, 2009 Is this what you want? #Include <String.au3> $Title = WinGetTitle("Game (") $Title = _StringSplit($title, "()", 0) MsgBox(0, '', $Title[1]) Link to comment Share on other sites More sharing options...
d0n Posted June 18, 2009 Author Share Posted June 18, 2009 both of them return 0 for me for some reason :S Link to comment Share on other sites More sharing options...
Malkey Posted June 19, 2009 Share Posted June 19, 2009 both of them return 0 for me for some reason :SYour original script implied the string in the variable $Title would have an opening bracket, "(", and a closing bracket, ")". And you required the string between these brackets to be returned.If the string in $Title has "any character or nothing( Return string) any character or nothing" format . Then my example should returns " Return string". Just tested and it does work on my XP with current AutoIt version.Looks like the best way is to use the way that works, your first post script. Link to comment Share on other sites More sharing options...
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