I have the following XML:
<t>a_35345_0_234_345_666_888</t>
I would like to replace the first occurrence of number after "_" with a fixed number 234. So the result should look like:
<t>a_234_0_234_345_666_888</t>
I have tried using the following but it does not work:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<xsl:value-of select='replace(., "(.*)_\d+_(.*)", "$1_234_$2")'/>
</xsl:template>
</xsl:stylesheet>
UPDATE
The following works for me (thanks @Chris85). Just remove the underscore and add "? to make it non greedy.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<xsl:value-of select='replace(., "(.*?)_\d+(.*)", "$1_234$2")'/>
</xsl:template>
</xsl:stylesheet>