Jump to content

i wrote a program that automatially deletes http(/s)://(/www.) from any thing it finds in the clipboard. - (Moved)


muchki
 Share

Recommended Posts

i wrote a program that automatially deletes http(/s)://(/www.) from any thing it finds in the clipboard.

now i want it to delete the 'page' specifiation (the ending) of the URL leaving only the whole site URL.

    my first guess is to 
############################################################################
    (a) put the value of the variable set to clipget() into an array of single characters 
        ###    here is my question: #### how do i do that?   ###;
############################################################################
    (b) point to the third backslash in the string ;
    (c) set the value to null;
    (d) move to the next argument and do the same;
    (e) repeat until end of array;
    (f) write the values of the array to a variable
    (g) clipput() the string
    (h) exit 
i'm new to autoit.

how do i load a variable containing the arguements of clipget() into an array?

many thanks in advance

this is what i have until now:

i.stack.imgur.com/gJMYo.png

Click2Trim.au3

Edited by muchki
Link to comment
Share on other sites

@muchki - Welcome to the forum. :)

This seems to be a question you are asking, and you are likely to get it noticed more (and more responses) if you post in the General Help forum section.

I recommend you use the Report post option (top right) to ask a MOD to move it to that forum.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

On 12/16/2019 at 8:47 PM, muchki said:

i wrote a program that automatially deletes http(/s)://(/www.) from anything it finds in the clipboard. Now i want it to delete the 'page' specifiation (the ending) of the URL leaving only the whole site URL.

$sURLFull can contain one, but also multiple URLs. Set this variable with ClipGet. Result : an array with 1..n matches or error.

; from : https://www.autoitscript.com/forum/topic/190236-replace-url-and-split/
#include <StringConstants.au3>
#include <Array.au3>

Local $sURLFull, $sPattern, $aArray
$sURLFull = "Text with different URL's im e.g. https://www.autoitscript.com/forum/topic/169097-forum-rules/" & @CRLF & _
            " or another one https://autoit.de/wcf/forenregeln/" & @CRLF & _
            " and www.autoit.de/subdir/"

$sPattern = "(?m)(?:https?:\/\/)?(?:www\.)?((?:[a-zA-Z\x{00a1}-\x{ffff}0-9.\-])+(?:\.[a-zA-Z]{2,63}))"
$aArray = StringRegExp($sURLFull, $sPattern, $STR_REGEXPARRAYGLOBALMATCH )
If @error Then
    ConsoleWrite ("! >>> Error : " & @error & @CRLF)
Else
    _ArrayDisplay($aArray)
EndIf

 

Edited by Musashi
added @error check

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Here one regexp way :

#include <Constants.au3>
#include <GUIConstants.au3>

Opt ("MustDeclareVars", 1)

Const $aURL[] = ["http://autoitscript.com/blablabla", _
  "https://autoitscript.com/blablabla", _
  "http://www.autoitscript.com/blablabla", _
  "https://www.autoitscript.com/blablabla"]

For $i = 0 To UBound($aURL)-1
  ConsoleWrite (StringRegExp($aURL[$i],"(?i)https?:\/\/(?:www.|)(.+?)\/",$STR_REGEXPARRAYMATCH)[0] & @CRLF)
Next

But to answer your question in (a), check StringSplit ($sString, "") will create an array of single characters

Edited by Nine
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...