I have input field like below
<BID>123-HSB-456789</BID>
Where i would like to reverse the contents of this field My expected outcome should be like below
<BID>456789-HSB-123</BID>
I have even tried the reverse funtion.... but it is not working
https://xqueryfiddle.liberty-development.net/nc4P6yf/1
Any help here
You've only given one test case, and one test case doesn't make a specification. For example, you haven't told us whether the element's value will always have two hyphens in it.
Here are three expressions that will do what you need on this test case, but they aren't equivalent, and will do different things with different test cases:
tokenize($in, '-') => reverse() => string-join('-')
replace($in, '([0-9]*)-([A-Z]*)-([0-9]*), '$3-$2-$1')
substring($in, 12, 3) || '-' || substring($in, 8, 3) || '-' || substring($in, 1, 6)
P.S. Please make sure you understand the code before using it, and test it on a range of inputs.
PP.S. There are constructs here that need XQuery 3.0 or 3.1.