Jump to content
Sign in to follow this  
erezlevi

text within an active window selecting only what is needed

Recommended Posts

erezlevi

hi,

I am looking for a way to select a certain phrase within a text following a keyword. like: if I have multiple lines:

"got information from server for user 2345"

"didn't get information from server for user 5566".

"got information from server for user 8899"

"got infromation from server for user 9999"

"didn't get information from server for user 5454".

how can i go directly to the "didn't" word and then skip within that line to "5566" and put 5566 in an integer $i?

also the same will apply to user 5454.

the information is within a window so i am using the "wingettext".

Thanks for everyone who will answer.

Share this post


Link to post
Share on other sites
SmOke_N

#include <array.au3>
$sString = ClipGet();I copied your text you put that you wanted to read, you'd replace clipget with your own way of getting the text
$a = StringRegExp($sString, "(?s)(?i)didn't.+?(\d+)", 3)
_ArrayDisplay($a)
If you need any other explanation, I'd suggest looking in the help file to understand what was done here, seeing as you didn't provide an effort code to begin with.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
rasim

hi,

I am looking for a way to select a certain phrase within a text following a keyword. like: if I have multiple lines:

"got information from server for user 2345"

"didn't get information from server for user 5566".

"got information from server for user 8899"

"got infromation from server for user 9999"

"didn't get information from server for user 5454".

how can i go directly to the "didn't" word and then skip within that line to "5566" and put 5566 in an integer $i?

also the same will apply to user 5454.

the information is within a window so i am using the "wingettext".

Thanks for everyone who will answer.

Example:

#include <Array.au3>

Global $SortTxtArr[1]

$text = WinGetText("test - Notepad")
$SplitString = StringSplit($text, @CRLF)

For $i = 1 To $SplitString[0]
    If StringInStr($SplitString[$i], "didn't") Then
        $varStr = StringRegExpReplace($SplitString[$i], "[^0-9]", "")
        _ArrayAdd($SortTxtArr, $varStr)
    EndIf
Next

_ArrayDisplay($SortTxtArr)
Edited by rasim

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  

×