Page 1 of 1

String manipulation issue (SOLVED)

Posted: 12 Mar 2014, 06:28
by brix
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

Re: String manipulation issue

Posted: 12 Mar 2014, 07:39
by smorgasbord
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")

Re: String manipulation issue

Posted: 12 Mar 2014, 19:39
by brix
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

Re: String manipulation issue

Posted: 12 Mar 2014, 21:57
by uname

Code: Select all

msgbox % RegExReplace("http://www.imdb.com/title/tt1442449/?ref_=fn_al_tt_1"
    , "\?.+$", "episodes?season=1")

Re: String manipulation issue

Posted: 12 Mar 2014, 22:09
by smorgasbord

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....:)

Re: String manipulation issue

Posted: 13 Mar 2014, 03:52
by brix
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!

Re: String manipulation issue (SOLVED)

Posted: 13 Mar 2014, 04:25
by smorgasbord
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