Skip to content

Instantly share code, notes, and snippets.

@ijy
Created September 15, 2013 16:35
Show Gist options
  • Select an option

  • Save ijy/6572314 to your computer and use it in GitHub Desktop.

Select an option

Save ijy/6572314 to your computer and use it in GitHub Desktop.
XSLT 1.0 search and replace template.
<!--
SEARCH & REPLACE
string: The text to be evaluated
search: The character or string to look for in the above string
replace: What to replace it with
The output will neatly concatenate the string with replacements made.
-->
<xsl:template name="search-and-replace">
<xsl:param name="string" />
<xsl:param name="search" />
<xsl:param name="replace" />
<xsl:value-of select="concat(substring-before($string, $search), $replace, substring-after($string, $search))" />
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment