IP- - ...">

How can I extract only numbers after a specific character?

There is a node of the following content.

<item is_json_array="yes">
  <name>   IP- - 1  (  1U #817)</name>
  <amount>156.48</amount>
  <taxrate>0</taxrate>
  <taxamount>0.00</taxamount>
  <notaxamount>156.48</notaxamount>
</item>

I need to wrest from a substring namecontaining only the digits after the character #. 817for the first non-numeric character or end of line. numeric characters can be any number

+4
source share
1 answer

Since you are using XSLT 1.0, you can use a combination of substring-after()and translate()to not only get the text after #, but also to remove any unwanted characters.

Example...

<xsl:template match="name">
  <xsl:value-of select="translate(substring-after(.,'#'),translate(substring-after(.,'#'),'0123456789',''),'')"/>
</xsl:template>

Here you can see the full working example: http://xsltfiddle.liberty-development.net/gWcDMes/1

+3
source

Source: https://habr.com/ru/post/1694493/


All Articles