Sign in to follow this  
Followers 0
WhiteCrow

About StringRegExp and more

10 posts in this topic

#1 ·  Posted (edited)

I need a StringRegExp that can find a number before a .jpg in a url

and then parse it to go one number higher

for example:

this one works fine with my program

$klad="http://agrolink.moa.my/did/drainage/menunews/SMART-Sign020604/SigningPhotos/006.jpg"

but this doesnt

$klad="http://agrolink.moa.my/did/drainage/menunews/SMART-Sign020604/SigningPhotos/smart006.jpg"

it want it to work with any url

for example

$klad="http://www.blah.com/blah/blah0000000056"

should return

$klad="http://www.blah.com/blah/blah0000000057"

but it doesnt, i think it has something to do with

$pattern = "gpj.(\d*?)/"

Who could help me out to get this piece of *** to work :whistle:

ps i reverse the $var becouse i think that way :dance:

#Include <Constants.au3>
#Include <string.au3>

$count=0
$count1=0
$count2=0
$counter=1
$picurl_int=0


$msg = ""
$picurl = ""
$jpggetal = ""
$numberparse = ""
$nummer = ""
$nparse=""



$klad="http://agrolink.moa.my/did/drainage/menunews/SMART-Sign020604/SigningPhotos/006.jpg"

; $klad omdraaien

$jpggetal = _stringReverse($klad)

;MsgBox (0, "kladblok", $klad)

;MsgBox (0, "omgekeerd", $jpggetal)

$pattern = "gpj.(\d*?)/"

$y = StringRegExp($jpggetal,$pattern,1)

$error = @error
If @error = 0 and @extended = 1 Then
    For $z = 0 to UBound($y) - 1
        $jpggetal = $y[$z]
    Next
Else
    msgbox(0,"error","@error = "    &  $error & @CRLF & "@extended = " & @extended)
EndIf

$picurl = _stringReverse($jpggetal)

$count1= StringLen ($picurl)

MsgBox (0, "stringregfound", $picurl, 2)

$picurl_int = Number($picurl)
;MsgBox (0, "stringregfound _ int", $picurl_int, 2)

$picurl_int = $picurl_int + 1

$picurl_int = String ($picurl_int)
$count2 = StringLen ($picurl_int)

;MsgBox (0, "stringregfound+1", $picurl_int, 2)

$counter = $count1 - $count2

Do

$picurl_int = "0" & $picurl_int

$counter=$counter-1
Until $counter=0

MsgBox (0, "stringregfound", $picurl_int, 2)

$count1= StringLen ($picurl) + 4

$klad = StringTrimRight ($klad, $count1)
$klad = $klad & $picurl_int & ".jpg"

MsgBox (0, "Result", $klad, 2)

btw the comments are mostly Dutch (my apologies :( )

and the messageboxes are for debugging

the vars i declared and dont use.. i like to keep some "free" ones, helps me to scroll less :dance:

Thanks in advance

Auto-it has the best helping user-base compared to any other scripting language..

Edited by WhiteCrow

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

is this what you are after ?

$klad = "http://agrolink.moa.my/did/drainage/menunews/SMART-Sign020604/SigningPhotos/006.jpg"

$klad = StringRegExp($klad, '(\d*)', 3)

$klad = $klad[UBound($klad)-1]

MsgBox(0, '', $klad)
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

Wow wouter, yes this actually works.

way simpler then what i made :whistle:

thanks man.

Feel so stupid right now.

Share this post


Link to post
Share on other sites

I do learn everyday :dance:

But im a bit slow sometimes :whistle:

This is what i made of it.. its sloppy, but it does the job(mostly)

===-- The PictureZapper --===

= is to get the next picturenumber up

- is to get the next picturenumber down

] is to exit the program

#Include <Constants.au3>
#Include <string.au3>

$infinite=1

$count=0
$count1=0
$count2=0
$counter=1
$picurl_int=0
$msg = ""
$picurl = ""
$jpggetal = ""
$numberparse = ""
$nummer = ""
$nparse=""

Opt("SendKeyDelay", 0)
HotKeySet ( "=", "GetPic_Up" )
HotKeySet ( "-", "GetPic_Down" )
HotKeySet ( "]", "Exits" )

Do
Sleep(200)
Until $infinite=999



Func Getpic_Up()

MouseClick ("left", 1071, 66, 1, 0)
Sleep(100)
Send("^a")
Sleep(100)
Send("^c")
Sleep(100)
$klad=Clipget()

$kladcopy = $klad

$klad= StringRegExp($klad, '(\d*)', 3)

$jpggetal = $klad[UBound($klad)-1]

;MsgBox(0, '', $jpggetal)

$picurl = $jpggetal

$count1= StringLen ($picurl)
;MsgBox (0, "stinrlen", $count1, 2)
;MsgBox (0, "stringregfound", $picurl, 2)

$picurl_int = Number($picurl)
;MsgBox (0, "stringregfound _ int", $picurl_int, 2)

$picurl_int = $picurl_int + 1

$picurl_int = String ($picurl_int)
$count2 = StringLen ($picurl_int)

;MsgBox (0, "stringregfound+1", $picurl_int, 2)

$counter = $count1 - $count2

Do

if $counter > 0 then
$picurl_int = "0" & $picurl_int
endif

$counter=$counter-1
Until $counter <1

;MsgBox (0, "stringregfound", $picurl_int, 2)

$count1= StringLen ($picurl) + 4

$kladcopy = StringTrimRight ($kladcopy, $count1)
$kladcopy = $kladcopy & $picurl_int & ".jpg"

;MsgBox (0, "uiteindelijke uitkomst", $kladcopy, 2)

MouseClick ("left", 1071, 66, 2, 0)
Sleep(100)
Send("^a")
Sleep(100)
ClipPut($kladcopy)
Send("^v")
Sleep(100)
Send("{Enter}")
EndFunc

;===========================================================

Func Getpic_Down()

MouseClick ("left", 1071, 66, 1, 0)
Sleep(100)
Send("^a")
Sleep(100)
Send("^c")
Sleep(100)
$klad=Clipget()

$kladcopy = $klad

$klad= StringRegExp($klad, '(\d*)', 3)

$jpggetal = $klad[UBound($klad)-1]

;MsgBox(0, '', $jpggetal)

$picurl = $jpggetal

$count1= StringLen ($picurl)
;MsgBox (0, "stinrlen", $count1, 2)
;MsgBox (0, "stringregfound", $picurl, 2)

$picurl_int = Number($picurl)
;MsgBox (0, "stringregfound _ int", $picurl_int, 2)

$picurl_int = $picurl_int - 1

$picurl_int = String ($picurl_int)
$count2 = StringLen ($picurl_int)

;MsgBox (0, "stringregfound+1", $picurl_int, 2)

$counter = $count1 - $count2

Do

if $counter > 0 then
$picurl_int = "0" & $picurl_int
endif

$counter=$counter-1
Until $counter <1

;MsgBox (0, "stringregfound", $picurl_int, 2)

$count1= StringLen ($picurl) + 4

$kladcopy = StringTrimRight ($kladcopy, $count1)
$kladcopy = $kladcopy & $picurl_int & ".jpg"

;MsgBox (0, "uiteindelijke uitkomst", $kladcopy, 2)

MouseClick ("left", 1071, 66, 2, 0)
Sleep(100)
Send("^a")
Sleep(100)
ClipPut($kladcopy)
Send("^v")
Sleep(100)
Send("{Enter}")
EndFunc

Func Exits()
exit
EndFunc

I hope sombody can use this :dance:

Its for Firefox, with 1280 x 1024 resolution

Share this post


Link to post
Share on other sites

If the page isnt a picture, the program crashes.

I get this:

$jpggetal = $klad[UBound($klad)-1]
$jpggetal = $klad^ ERROR

Error: Subscript used with non-Array variable.

Im really not a programmer, i cant fix this, tried several things.

This is just a free time tid-bit im fiddling with :whistle:

Anyone, help me on my way ?

Share this post


Link to post
Share on other sites

regexp helpfile, @error & @extended.

<{POST_SNAPBACK}>

Its not that kind of error..

But thanks for your help sofar, youve been helpfull :whistle:

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You were right, but the @extended or @error didnt work, but this was even simpler :

$klad= StringRegExp($klad, '(\d*)', 3)

if $klad="" then
MsgBox(0, "","Find a page with pictures....")

else
$jpggetal = $klad [UBound($klad)-1]
endif

That i didnt see this, so simple :">

Thanks again Wouter.

Edited by WhiteCrow

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