I’m trying to find a word and replace it with a link. So for example:
<root>
<description>
Uniquely cultivate optimal supply chains before multidisciplinary infrastructures.
</description>
</root>
In the xsl, I’m trying to search a particular word and replace that word with a link. For example I want to replace the word “cultivate” with cultivate so the final output on the page will be:
Uniquely <a href="http://google.com">cultivate</a> optimal supply chains before multidisciplinary infrastructures.
I’m approaching this problem using replace function like:
<xsl:variable name="description" select="description" />
and then
replace($description, "(.*)(cultivate.*)", "$1test$2")
This just adds the word test before cultivate. I would really appreciate any help.
–UPDATE–
I was able to fix this issue using replace like this
<xsl:variable name="description" select="description" />
Description: <xsl:value-of disable-output-escaping="yes" select="replace($description, '(.*)(cultivate)(.*)', '$1<a href=http://google.com >cultivate</a>$3')" />
Use
analyze-stringhttp://www.w3.org/TR/xslt20/#regex-examples e.g.