XSLT transformation: Substring after a last special character
I have fields "commercial register code: 111开发者_JAVA技巧1111" and "commercial register code 2222" I need to take after last space symbols: 1111111 and 2222. There is function to take symbolrs before "space" in xsl?
Regards
Update from comments
I will have "comercial register 21 code:" line
And
"code" can be without ":" symbol
If there is going to be one and only one number, then you could use
translate($string,transtale($string,'0123456789',''),'')
This will remove any not digit character from the string.
If the prefixed label is stable, then you could use something like:
substring-after($string,'commercial register code:')
Abour the question:
There is function to take symbolrs before "space" in xsl?
Answer: Yes, substring-before()
function
Update
From comments, it looks like the string pattern would be:
'commercial register' number 'code' (':')? number
Then use:
translate(substring-after($string,'code'), ': ', '')
In XSLT 2.0, use tokenize($in, '\s+')[last()]
If you're stuck with 1.0, you need a recursive template: check out str:tokenize in the EXSLT library.
Can you use EXSLT functions? If so, there is a str:split function and then you can do:
str:split($string, ' ')[position()=last()]
精彩评论