I think I'm just having too much trouble understanding how to use regex and creating links...
I'm working on a Greasemonkey script for a virtual pet game that will create links to the wiki for each creature listed on a certain page. The problem is, new pets get added to the page all the time so I can't just hardcode the links into the script. I need to search for the creatures names and then make it a link...
You can view the target page without signing up.
Sample source code from the target page:
<tr>
<td>Flizzard</td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
</tr>
<tr>
<td>Fluff</td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><img src="./images/icons/yes.png" /></td>
<td align="center"><a href="accomplishments.php?family=Fluff&acc=exalted"><img src="./images/icons/no.png" border="0" /></a></td>
<td align="center"><a href="accomplishments.php?family=Fluff&acc=herd"><img src="./images/icons/no.png" border="0" /></a></td>
</tr>
.
.
"Flizzard" and "Fluff" would be what I want to turn into links... I found this and started working on it, and it might work, except it doesn't seem to say where to start the match (in a way that makes sense to me anyways), and I have NO clue what to put in (The-Identifier-That-Denotes-End-Of-Text-Of-Interest)
var html = document.body.innerHTML;
html = html.replace( /(http://wiki.unicreatures.com/index.php?title=)(.*?)(The-
Identifier-That-Denotes-End-Of-Text-Of-Interest)/g, $1<a href="path/to/$2">$2</a>$3
);
document.body.innerHTML = html;
.
Could somebody maybe please try to explain how that regex works, and what would work for (The-Identifier-That-Denotes-End-Of-Text-Of-Interest) since I don't seem to see any punctuation or spaces after the creatures names?
Thanks!
(Please NO jQuery info... javascript is enough to wrap my brain around right now LOL)