String manipulation issue (SOLVED)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
brix
Posts: 14
Joined: 20 Feb 2014, 09:35

String manipulation issue (SOLVED)

12 Mar 2014, 06:28

Hi,

I have this issue trying to manipulate a string witch is an url

the code i try is :

Code: Select all

			
Loop %	(i :=wb.document.all.tags["tr"]).length
				{
					if	(i[A_Index-1].className="findResult odd")
					{
						lienimdb := wb.document.all[i[A_Index-1].sourceIndex].href
						lienimdb1 := RegExMatch(lienimdb, "\?")
						lienimdb2 := Substr(lienimdb, 1, lienimdb1-1)
                                                lienimdb3 := RegExReplace (lienimdb, lienimdb2, "episodes\?season=1")
						}
}
I tried other way with stringreplace, Substr but the msbbox is always empty.

I just want to have http://www.imdb.com/title/ttXXXXXX/ ( wich is lienimdb2 ) + episodes\?season=1

Someone have an idea ?

Regard
Last edited by brix on 13 Mar 2014, 03:47, edited 1 time in total.
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: String manipulation issue

12 Mar 2014, 07:39

Something like this ?

Code: Select all

url = http://www.imdb.com/title/tt1442449/?ref_=fn_al_tt_1
MsgBox % required := RegExReplace(url, "(http://www\.imdb\.com/title/tt(.*)/)(.*)", "$1")
John ... you working ?
brix
Posts: 14
Joined: 20 Feb 2014, 09:35

Re: String manipulation issue

12 Mar 2014, 19:39

Hi,
sorry i think i didn't make a clear post,

what i want is to have this :

Code: Select all

 http://www.imdb.com/title/tt1442449/episodes?season=1
from this :

Code: Select all

http://www.imdb.com/title/tt1442449/?ref_=fn_al_tt_1
but for exemple this don't work :

Code: Select all

var := required + "episodes\?season=1"
btw thank you is faster way to do whant takes me 2 lines ( but it's still hard to understand reg ex )

regards
User avatar
uname
Posts: 23
Joined: 25 Oct 2013, 12:50

Re: String manipulation issue

12 Mar 2014, 21:57

Code: Select all

msgbox % RegExReplace("http://www.imdb.com/title/tt1442449/?ref_=fn_al_tt_1"
    , "\?.+$", "episodes?season=1")
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: String manipulation issue

12 Mar 2014, 22:09


btw thank you is faster way to do whant takes me 2 lines ( but it's still hard to understand reg ex )

regards
lol

yes regex is faster way to do....:)
John ... you working ?
brix
Posts: 14
Joined: 20 Feb 2014, 09:35

Re: String manipulation issue

13 Mar 2014, 03:52

uname wrote:

Code: Select all

msgbox % RegExReplace("http://www.imdb.com/title/tt1442449/?ref_=fn_al_tt_1"
    , "\?.+$", "episodes?season=1")
Thats perfect thans you very much!
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: String manipulation issue (SOLVED)

13 Mar 2014, 04:25

And i thought you needed something like this

it shall take time... to load the result.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
        ;~ <title>The Walking Dead: The Game - Season 1, Episode 2: Starved for Help (Video Game 2012) - IMDb</title>

string = season

FileDelete, text.txt

URLDownloadToFile, http://www.imdb.com/title/tt2178956/, text.txt

Loop
{

filereadline, k, text.txt, %A_index%

	IfInString, k, %string%
		{
			k := RegExReplace(k, "(.*)Season\s(.*)\,\sEpisode\s(.*):(.*)", "Season$2 Episode$3")
			MsgBox % k
			exitapp
		}

}
esc::Exitapp
John ... you working ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, justcop, Rohwedder and 169 guests