Formatting string (Removing leading zeros)

后端 未结 8 2148
鱼传尺愫
鱼传尺愫 2021-01-11 10:07

I am newbie to xslt. My requirement is to transform xml file into text file as per the business specifications. I am facing an issue with one of the string formatting issue.

8条回答
  •  独厮守ぢ
    2021-01-11 10:55

    As a simple alternative in XSLT 2.0 that can be used with numeric or alpha-numeric input, with or without leading zeros, you might try:

    replace( $value, '^0*(..*)', '$1' )
    

    This works because ^0* is greedy and (..*) captures the rest of the input after the last leading zero. $1 refers to the captured group.

    Note that an input containing only zeros will output 0.

提交回复
热议问题