Sign in to follow this  
Followers 0
BigEdJr

Parse text from clipboard

4 posts in this topic

Hi All,

I am pretty new to this whole scripting thing, but I am enjoying it. I appreciate all the knowledge you all share too.

I am trying paste the last line of text from info I am grabbing from a webpage. When I manually do it it looks like this:

***********************************

Activity - Sessions

Sessions

Add Delete Edit

User Session ID Logged On Minutes since last heartbeat Dual Monitor

1 mseid xx5A 6/16/2008 2:21:52 PM 3 No

2 m3449 xx01 6/16/2008 1:30:24 PM 4 No

3 kdinu xx4D 6/16/2008 1:23:25 PM 1 No

4 lstan xx49 6/16/2008 2:21:40 PM 3 No

5 rhoop xx18 6/16/2008 1:44:31 PM 0 No

6 lstan xxCD 6/16/2008 2:12:49 PM 2 No

7 tclar xx98 6/16/2008 2:02:35 PM 2 No

8 dlawl xx24 6/16/2008 2:22:21 PM 2 Yes

9 m2561 xx44 6/16/2008 1:46:56 PM 3 No

10 ggarc xx46 6/16/2008 1:41:20 PM 3 No

11 lnels xxEB 6/16/2008 1:58:54 PM 1 No

12 m1813 xxDB 6/16/2008 1:14:19 PM 0 No

13 m3910 xx12 6/16/2008 1:44:10 PM 0 No

14 m2448 xx56 6/16/2008 1:37:15 PM 2 No

Query returned: 14

************************************************

All I care about is the "Query returned: x". Is there a way to just paste or send that one to a text file? I am able to get everything (currently using send ("^v")) but I'd like to learn how to parse that info out.

Thanks!

Share this post


Link to post
Share on other sites



Hi and wellcome :)

All I care about is the "Query returned: x". Is there a way to just paste or send that one to a text file? I am able to get everything (currently using send ("^v")) but I'd like to learn how to parse that info out.

You can use StringRegExp...

;Get the clipboard data
$ClipBoard_Content = ClipGet()

;Parse it via RegExp
$Query_Returned = StringRegExpReplace($ClipBoard_Content, "(?i)(?s).*?Query returned: (\d+).*?$", "\1")

;Show the results
MsgBox(64, "Results", "Query Returned: " & $Query_Returned)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hi and wellcome :)

You can use StringRegExp...

;Get the clipboard data
$ClipBoard_Content = ClipGet()

;Parse it via RegExp
$Query_Returned = StringRegExpReplace($ClipBoard_Content, "(?i)(?s).*?Query returned: (\d+).*?$", "\1")

;Show the results
MsgBox(64, "Results", "Query Returned: " & $Query_Returned)

Well, that works perfectly. Thank you very much!

Would you mind explaining what all this does/means?

"(?i)(?s).*?Query returned: (\d+).*?$", "\1"

I can use what you gave me fine I just want to understand how and why it works.

Thanks again!

Share this post


Link to post
Share on other sites

Would you mind explaining what all this does/means?

I can use what you gave me fine I just want to understand how and why it works.

This is Regular Expressions, look for StringRegExp() function in the help file for the details.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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