Replace list of words with associated links
Posted: Sun Dec 03, 2006 5:05 pm
I have a list of words and corresponding links eg.
dog http://www.bigdog.com
cat http://www.nicecat.com
fox http://www.fox.com
Can I have one regular expression that will replace all the words on the left hand side of the list (ie. dog, cat, fox) with the left hand side (http://www.bigdog.com, http://www.nicecat.com, http://www.fox.com)?
Lets take an input string:
The dog saw the cat and fox laughing.
I want the output to be:
The <a href="http://www.bigdog.com">dog</a> saw the <a href="http://www.nicecat.com">cat</a> and <a href="http://www.fox.com">fox</a> laughing.
I will take the word/link list as xml eg;
<masterlist>
<keyword>
<text>dog</text>
<url>http://www.bigdog.com</url>
</keyword>
<keyword>
<text>cat</text>
<url>http://www.nicecat.com</url>
</keyword>
<keyword>
<text>fox</text>
<url>http://www.fox.com</url>
</keyword>
</masterlist>
I am also using msxsl c# script for the reular expression.
Can anyone help me please?
dog http://www.bigdog.com
cat http://www.nicecat.com
fox http://www.fox.com
Can I have one regular expression that will replace all the words on the left hand side of the list (ie. dog, cat, fox) with the left hand side (http://www.bigdog.com, http://www.nicecat.com, http://www.fox.com)?
Lets take an input string:
The dog saw the cat and fox laughing.
I want the output to be:
The <a href="http://www.bigdog.com">dog</a> saw the <a href="http://www.nicecat.com">cat</a> and <a href="http://www.fox.com">fox</a> laughing.
I will take the word/link list as xml eg;
<masterlist>
<keyword>
<text>dog</text>
<url>http://www.bigdog.com</url>
</keyword>
<keyword>
<text>cat</text>
<url>http://www.nicecat.com</url>
</keyword>
<keyword>
<text>fox</text>
<url>http://www.fox.com</url>
</keyword>
</masterlist>
I am also using msxsl c# script for the reular expression.
Can anyone help me please?