XSLT: Finding last occurence in a string

前端 未结 4 1989
轮回少年
轮回少年 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 00:59

    Generalized one -

    substring($string,1, string-length($string)-string-length(str:split($string, '_')[count(str:split($string, '_'))]))
    

    Idea is to get the index of last occurrence by splitting string.

    Index of last occurrence = string-length($string) - length of last string after split

提交回复
热议问题