Jump to content

[SOLVED] Regex


E3pO

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.