Jump to content

better way to do this?


 Share

Recommended Posts

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

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

both of them return 0 for me for some reason :S

Your 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

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...