E3pO Posted May 22, 2009 Share Posted May 22, 2009 Hello, back again but this time with some javascript questions! I'm doing some regex on a webpage and i need to get the file name, blah.zip, in <p><b>File Name:<b> blah.zip<br> I've come up with the following, var dl_url = document.documentElement.innerHTML.match(/<p><b>File Name:</b> (.*?)<br>); top_ad_box.innerHTML = dl_url; but the code breaks at <p><b>File Name:</b> (.*?)<br> What should i do to make that pass? Thanks. Link to comment https://forums.phpfreaks.com/topic/159186-solved-regex/ Share on other sites More sharing options...
Ken2k7 Posted May 22, 2009 Share Posted May 22, 2009 Escape it with \ Link to comment https://forums.phpfreaks.com/topic/159186-solved-regex/#findComment-839522 Share on other sites More sharing options...
E3pO Posted May 22, 2009 Author Share Posted May 22, 2009 Escape it with \ Still doesn't work? Are you sure? I already tried that. var dl_url = document.documentElement.innerHTML.match(/<p><b>File Name:<\/b> (.*?)<br>/i); top_ad_box.innerHTML = dl_url; Link to comment https://forums.phpfreaks.com/topic/159186-solved-regex/#findComment-839524 Share on other sites More sharing options...
Ken2k7 Posted May 22, 2009 Share Posted May 22, 2009 What element is document.documentElement anyways? Can you show me the HTML you're working with? Link to comment https://forums.phpfreaks.com/topic/159186-solved-regex/#findComment-839626 Share on other sites More sharing options...
E3pO Posted May 22, 2009 Author Share Posted May 22, 2009 Resolved.. <script type="text/javascript"> // ==UserScript== // @name HalomapsDL // @namespace Halomaps // @description HalomapsDownload // @include *.halomaps.org* //@author E3pO //@websiteurl http://wmclan.net/ // ==/UserScript== if(String(window.location).match(/http:\/\/hce\.halomaps\.org\//i)) { var r_text = new Array (); r_text[0] = "ftp://files1.halomaps.org/maps/"; r_text[1] = "ftp://files2.halomaps.org/maps/"; r_text[2] = "ftp://files3.halomaps.org/maps/"; var i = Math.floor(3*Math.random()) var top_ad_box = document.getElementById("top_ad_box"); var menu = document.getElementById("mainmenu"); var body = document.getElementsByTagName("body").innerHTML; var match, re = /File Name:<\/b> (.*?)<br>/img; match = re.exec(document.documentElement.innerHTML); top_ad_box.innerHTML = '<center>Download link grabber by E3pO. www.wmclan.net<hr /><a href="'+r_text[i]+match[1]+'"><img src="http://ts.wmclan.net/photos/misc/download.png" alt="Download" border="0"/></a></center><script type="text/javascript" src="http://ads.adbrite.com/mb/text_group.php?sid=1182091&br=1&dk=776f726b2066726f6d20686f6d655f305f325f776562"></script>'; menu.innerHTML = '<a href="./">Home Page</a><br/><a href="index.cfm?pg=4">Articles</a><br/><a href="http://forum.halomaps.org">User Forum</a><br/><a href="index.cfm?pg=66">Halo CE Servers</a><br/><a href="index.cfm?pg=91">Map ScreenShots</a><br/><a href="index.cfm?pg=92">ScreenShot Clan</a><br/><a href="index.cfm?pg=60">Submit Files</a><br/><a href="http://wmclan.net/">Wmclan</a><br/>'; } </script> Link to comment https://forums.phpfreaks.com/topic/159186-solved-regex/#findComment-839705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.