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
Share on other sites

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.