XSLT: Finding last occurence in a string

前端 未结 4 1974
轮回少年
轮回少年 2020-12-18 00:55

Given a form number like:

ABC_12345_Q-10

I want to end up with:

ABC12345

So I need to find the position o

4条回答
  •  有刺的猬
    2020-12-18 01:18

    concat(
        substring-before($s, '_'),
        substring-before(substring-after($s, '_'), '_')
    )
    

    Alternatively:

    string-join(tokenize($s, '_')[position() <= 2], '')
    

提交回复
热议问题