I have a requirement to remove leading zeros from a string value.
Example:
- 00012MD78009850 should become: 12MD78009850
- 78CA65430 should be kept the same: 78CA65430
My request is in the form of an XML:
<order>
<itemId>00012MD78009850</itemId>
</order>
I need to parse the value inside itemId and show 00012MD78009850 as 12MD78009850.
I tried to use:
fn-bea:trim-left(fn:replace(data(order/itemId), '0' ,''))
but this replaced all zeros and got the incorrect result 12MD78985.
You can try this:
fn:replace(data(order/itemId), '^0+', '')The
^means process everything at the beginning of a stringThe
0is the character you would like to process (remove, trim)The
+one or more occurrences