Sign in to follow this  
Followers 0
Fr33b0w

Ripping text from a clipboard

7 posts in this topic

#1 ·  Posted (edited)

Hey guys!

There should be simple way to rip multiple sentences from some page but I am not sure how to do it. I know I have to have delimiters and stuff like that, implemented... and I did try something but I am not sure how to do it anymore... I though it would be simple but it ain't. For example I wanted to COPY some text from a web page and all group of characters that are longer then 15 chars to write in some file or something. For example if I have a text and inside group of characters like:

this.is.something-i-would.like.to.save.in.a.file

and this is not what i want to be saved

this-again-is.something_i_would.like-to.have.saved

and this line aint

so if i copy that text what would be easiest way to check how many chars are connected without "delimiter" which would be "space" between all them and then to choose to save group of chars that are not separate with "space" but with those "-._" (more then 20 chars or whatever the number should be set). I know I have to set delimiter as "space" but I am not sure anymore how to do it. So I did try to use lines like

Stringsplit(FileReadLine($stringa,$stringb)," ")

But... I got lost... somewhere...

For those who know how to do it I bet it is just few lines, right?

Thanks in advance!

Edited by Fr33b0w

Share this post


Link to post
Share on other sites



If they are always line breaks between them, like in your example, you could do...

StringSplit(FileReadLine($stringa,$stringb),@crlf,1)

Then loops through that array using StringInStr to find valid seperator characters

They are not... I am not sure how to check them if there is 20 chars or more then 20 chars and no space between them, and then to save that group of chars in separate file or clipboard again. For example, when I copy info from that page to get sorted in clipboard just those which are in groups of 20 chars or more and separate with space... There must be a simple few lines code but I don't know how to do it... Also never worked with arrays. I know how it sounds but I am sorry... have been writing just simple autoit scripts. This one and one with sorting text where m23 helped me was a problematic ones... I know this one is very simple but I even don't know how to start...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Stil dont understand 100% about what do you need to save, do you need to save only that word or whall line?

Do this help?

#include <Array.au3>
Dim $array[1]
$chars = StringSplit(StringReplace(FileRead(FileOpen("log.txt", 0)),@CRLF," ")," "); change log.txt to your filename
For $x = 1 To $chars[0]
    If StringLen($chars[$x]) > 20 Then; word len
        If $array[0] = "" Then
            $array[0] = $chars[$x]
        Else
            _ArrayAdd($array,$chars[$x])
        EndIf
    EndIf
Next
_ArrayDisplay($array)
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Stil dont understand 100% about what do you need to save, do you need to save only that word or whall line?

Do this help?

#include <Array.au3>
Dim $array[1]
$chars = StringSplit(StringReplace(FileRead(FileOpen("log.txt", 0)),@CRLF," ")," "); change log.txt to your filename
For $x = 1 To $chars[0]
    If StringLen($chars[$x]) > 20 Then; word len
        If $array[0] = "" Then
            $array[0] = $chars[$x]
        Else
            _ArrayAdd($array,$chars[$x])
        EndIf
    EndIf
Next
_ArrayDisplay($array)

Wow You gave me a GREAT example how to work on it. Still there is one more char that I must add as delimiter. I will work on that now. YOU HELPED ME A LOT - THANKS!

Edited by Fr33b0w

Share this post


Link to post
Share on other sites

This looks like it works (at least on the test data you gave):

#include <Array.au3>
Local $string = "this.is.something-i-would.like.to.save.in.a.file" & @LF & "and this is not what i want to be saved" & @LF & "this-again-is.something_i_would.like-to.have.saved" & @LF & "and this line aint"

Local $longStrings = StringRegExp ($string, "\s*(\S{15,})\s+", 3)
_ArrayDisplay ($longStrings)


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

I got the solution from previous example and did the whole script exact I wanted it to be. But this is also another dimension I could learn from. Thanks a lot to both of You!

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