View Full Version : parse href attribute?

08-28-2010, 10:15 AM
Right, so there are a bunch of links in this format:
<a href="/profiles/########">username</a>

I'm using greasemonkey, and what I want to do is go through and get all of the /profiles/######## part of the anchor tag. I'm using Regex and I can't seem to get a match.

This is what I have so far:

function ok() {
var names = document.getElementsByTagName('a');
var reg = new RegExp("WHAT GOES HERE?");
var e = "links:\n";

var i = 0;

while(i<10) {
e += reg.exec(names[i].href) + "\n";



what is actually desired is I want there to be a way I can select these somehow as well..

08-28-2010, 10:33 AM
K so I've figured out my problem.. I needed to use getElementsByClassName.. now that I have the numbers, I still need to figure out a way to get them out of the document. I'd rather not make a giant 200 line alert window, is there another easier way? Also, how do I filter out the null results?