From: http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx
Here's a sample template that lets you have the string. replace () functionality in XSLT 1.0. the template "string-replace-all" takes 3 parameters and recursively processes the input text string.
Text: Main string
Replace: the string fragment to be replaced
By: the replacement string
<XSL: Template Name = "string-replace-all">
<XSL: Param name = "text"/>
<XSL: Param name = "replace"/>
<XSL: Param name = "by"/>
<XSL: Choose>
<XSL: When test = "contains ($ text, $ replace)">
<XSL: value-of select = "substring-before ($ text, $ replace)"/>
<XSL: value-of select = "$ by"/>
<XSL: Call-Template Name = "string-replace-all">
<XSL: With-Param name = "text"
Select = "substring-after ($ text, $ replace)"/>
<XSL: With-Param name = "replace" select = "$ Replace"/>
<XSL: With-Param name = "by" select = "$ by"/>
</XSL: Call-template>
</XSL: When>
<XSL: otherwise>
<XSL: value-of select = "$ text"/>
</XSL: otherwise>
</XSL: Choose>
</XSL: Template>
Here's how it is called:
<XSL: variable name = "myvar">
<XSL: Call-Template Name = "string-replace-all">
<XSL: With-Param name = "text" select = "'This is a sample text: {replaceme} and {replaceme} '"/>
<XSL: With-Param name = "replace" select = "'{replaceme}'"/>
<XSL: With-Param name = "by" select = "'string. Replace () in XSLT '"/>
</XSL: Call-template>
</XSL: Variable>
(Edit: Thanks to Marky and granadaco der for typing out the XSLT code in the comments .)
The resulting value of $ myvar after {replaceme} is replaced is"This is a sample text: String. Replace () in XSLT and string. Replace () in XSLT"
For those who are not familiar with XSLT syntax and here's the C # equivalent. An excellent material for the thedailywtf!
(Note: I'm not so sure, but I think in XSL 2.0 there is already a built-in replace function on strings)