Sign in to follow this  
Followers 0
jiglei

Retrieve whats between [ ] in a string.

4 posts in this topic

#1 ·  Posted (edited)

Hello. Once again im stuck within a problem that seems to be easy to solve... But I can't find anywhere how... :)

Here it goes:

I'm having Winlist to detect how many windows with a certain title exist, and then I make ControlGetText to check the text within those windows.

And then, when a certain text is found in the window, I want it to return me some text that is included in the window title, that for this case, is beetween [ ].

I'll give you this part of my script so that you can understand what i pretend, better:

$var = WinList("Wintitle")
    For $i = 1 to $var[0][0]
        $sText=ControlGetText($var[$i][0],"",606)
        If Stringinstr($sText, "The Text") Then "Tell Me whats beetween [] on $var[$i][0]"

Now I have no idea what to do so that autoit returns whats in the title, i can get the title, since it is $var[$i][0] but how can I make it to return ONLY whats beetween [ ] on the title? The title is something like: [This is what should be returned] "Other Stuff on the tile......"

Thanks for your attention, hope you can help me out with this, since this is stopping me from finishing my code :) .

EDIT: I've found another way to pass through my problem, but anyways I'd like to know how to pass this if this ever comes to me, Knowledge is never too much ;) .

Edited by jiglei

Share this post


Link to post
Share on other sites



Dim $aMatch = StringRegExp($var[$i][0], '\[([^]]*)\]', 1)
If IsArray($aMatch) Then $sText = $aMatch[0]

You could also use StringInStr and StringLeft or anything else to extract the substring from the string.

Share this post


Link to post
Share on other sites

Should be able to use _StringBetween() Func too.

Share this post


Link to post
Share on other sites

Should be able to use _StringBetween() Func too.

Works perfect for what I needed ^^

Thanks a lot.

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