Sign in to follow this  
Followers 0
d0n

StringRegExp pattern

15 posts in this topic

i am trying to get a pattern

attachment.php?aid=787795&k=ed6f1934ea92a037f4bbd102b7c80db9&t=1259460253&fid=8&sid=37f8lAaodEqWbOSkKY5XoH4xt5BqvMruZfXtDM5Wp%2BekDUE

in this line

<a href="attachment.php?aid=787795&amp;k=ed6f1934ea92a037f4bbd102b7c80db9&amp;t=1259460253&amp;fid=8&amp;sid=37f8lAaodEqWbOSkKY5XoH4xt5BqvMruZfXtDM5Wp%2BekDUE"  onmouseover="showMenu(this.id,false,2)" id="aid787795" target="_blank" title="">Show Ch01.torrent</a> (17.98 KB)

I have this but it doesn't seem to be getting the stuff in the bracket

$Link = StringRegExp($HTML, '.*?<a href="(.*?)".*?Show Ch01.torrent</a>.*?', 1)

Theres a bunch of crap before and after it, but i am not sure what is wrong

Share this post


Link to post
Share on other sites



Can you use _StringBetween? That would be much easier.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$Links = StringRegExp($HTML, '<a href="([^"]*)"[^>]*>Show Ch01.torrent</a>', 1)
$Link = $Links[0]

Try this. If the 0 index isn't right, try the 1 index ($Links[1] instead).

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

um because in the website's html, there is way more than 1 '<a href="' beginning of string to use _StringBetween :)

Share this post


Link to post
Share on other sites

$Links = StringRegExp($HTML, '<a href="([^"]*)"[^>]*>Show Ch01.torrent</a>', 1)
$Link = $Links[0]

Try this. If the 0 index isn't right, try the 1 index ($Links[1] instead).

Tried that just now, @error returns 1

Share this post


Link to post
Share on other sites

This works for me

$Link = StringRegExp($HTML, "(?i)<a\shref[\s=]+[\x22\x29](.+?)[\x22\x29]", 1)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

can i ask what \x22\x29 is? do they equal " ?

because using this is giving me HTML codes from before this line

Edited by d0n

Share this post


Link to post
Share on other sites

can i ask what \x22\x29 is? do they equal " ?

because using this is giving me HTML codes from before this line

\x22 = double quote

\x29 = single quote

If you are getting other lines before that then we will have to see a bit more of the html code to get the right link unless there is something in that link that is specific and never changes.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

<a href="attachment.php?aid=787795&amp;k=ed6f1934ea92a037f4bbd102b7c80db9&amp;t=1259460253&amp;fid=8&amp;sid=37f8lAaodEqWbOSkKY5XoH4xt5BqvMruZfXtDM5Wp%2BekDUE"  onmouseover="showMenu(this.id,false,2)" id="aid787795" target="_blank" title="">Show Ch01.torrent</a>

This doesn't change

<a href="

onmouseover="showMenu(this.id,false,2)"

target="_blank" title="">Show

Share this post


Link to post
Share on other sites

<a href="attachment.php?aid=787795&amp;k=ed6f1934ea92a037f4bbd102b7c80db9&amp;t=1259460253&amp;fid=8&amp;sid=37f8lAaodEqWbOSkKY5XoH4xt5BqvMruZfXtDM5Wp%2BekDUE"  onmouseover="showMenu(this.id,false,2)" id="aid787795" target="_blank" title="">Show Ch01.torrent</a>

This doesn't change

<a href="

onmouseover="showMenu(this.id,false,2)"

target="_blank" title="">Show

Those are also most likely common to all the links on the page too so they won't help. Can you provide a link to the page you are trying to read?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

sorry i think i forgot to mention that there is only 1 'Show Ch01.torrent' in the source of the site

that is why i tried something like this in the beginning but failed :)

$Link = StringRegExp($HTML, '.*?<a href="(.*?)".*?Show Ch01.torrent</a>.*?', 1)

Share this post


Link to post
Share on other sites

sorry i think i forgot to mention that there is only 1 'Show Ch01.torrent' in the source of the site

that is why i tried something like this in the beginning but failed :)

$Link = StringRegExp($HTML, '.*?<a href="(.*?)".*?Show Ch01.torrent</a>.*?', 1)

"(?i)<a\shref[\s=]+[\x22\x29](.+?)[\x22\x29].+Show\s*Ch01\.torrent"

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Actually that last one should be

"(?i)<a\shref[\s=]+[\x22\x29]*(.+?)[\x22\x29\s].+Show Ch01.torrent"


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

that one returns @error = 1 :S

EDIT: nvm got it, had an extra space

thank you for the help

Edited by d0n

Share this post


Link to post
Share on other sites

I just tested this and it works for me

$Link = StringRegExp($HTML, "(?i)<a\shref[\s=]+[\x22\x29]*(.+?)[\x22\x29\s].+Show\s*Ch01.torrent", 1)


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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