Jump to content
Sign in to follow this  
d0n

better way to do this?

Recommended Posts

d0n

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)

Share this post


Link to post
Share on other sites
Malkey

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)
;

Share this post


Link to post
Share on other sites
d0n

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

Share this post


Link to post
Share on other sites
Malkey

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.