Reputation: 841
I try to find string before closing element e.g. (277, 288
) then replace $1
return s/b 277
. (<)
not support my regex
Input XML
<root>
<p>Magno v College Network, Inc. (2016) 1 CA5th 277, 288</p>
<p>Magno v College Network, Inc. (5, 2017) 1 CA5th 15, 288 SA</p>
</root>
XSLT
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//text()">
<xsl:value-of select="replace(., '([0-9]+),\s[0-9]+(<)', '$1')"/>
</xsl:template>
Expected output
<root>
<p>Magno v College Network, Inc. (2016) 1 CA5th 277</p>
<p>Magno v College Network, Inc. (5, 2017) 1 CA5th 15, 288 SA</p>
</root>
Upvotes: 0
Views: 24
Reputation: 167506
What kind of numbers, only positive integers without any leading +
or -
symbol? Anyway, if you match with regular expressions, then the metacharacter $
indicates a match on the end of the string perhaps using it in your expression, as in '([0-9]+),\s[0-9]+$'
, suffices.
Upvotes: 1