07-31-2019 01:07 PM
I’m receiving data with 18 characters, which includes 7 leading 0s. Would I use the Mapper to TRIM off the leading 0s? If so how would I go about this?
Thank you
07-31-2019 02:10 PM
Hi Matt,
you can use the expression language, specifically the replace() method to achieve this.
expression: “0000000helloworld.”.replace(/([1]+)/, “”)
result: helloworld.
This uses a regex to trim ALL leading zeros from your given string.
If you would like to specifically always only remove the 7 leading zeros you can use this.
expression: “0000000helloworld.”.replace(“0000000”, “”)
result: helloworld.
which specifically removes the first 7 zeros found in the string, in this case the 7 leading zeros your looking to remove.
here is documentation in case you want to refer to it:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439357/String+Functions+and+Properties#St...
0 ↩︎
08-06-2019 09:12 AM
Thank you cjhoward18!
This did the job perfectly.
01-14-2022 12:24 AM
Hi @cjhoward18 ,
How can I extract number only from a string
My input is FR4535345, fgfh345
My out put should be 4535345,345
Is there any find index of a first digit in a string in snaplogic?
01-14-2022 03:14 AM
Hi @the_pan_zone,
You can use the .match()
function with the following regex included:
$string.match(/[0-9]+/g)