Forum Discussion

Banu's avatar
Banu
New Contributor
5 years ago

How to remove / in the data extraction

Hi Team,

can anyone help me how to remove / from the data.
for some i am getting / for some i am getting data as expected

3 Replies

  • viktor_n's avatar
    viktor_n
    Contributor II

    Hi @Banu

    If it’s string than you can use $data.replaceAll('/', '')
    But if it’s different type you can also try $data.toString() and after that add .replaceAll('/', '').

  • Banu's avatar
    Banu
    New Contributor

    Thanks Viktor that helped

    can you also help me to remove the data which contains / in the array.
    i want to eliminite that completley

  • viktor_n's avatar
    viktor_n
    Contributor II

    Hi @Banu

    This time you need to iterate through the array.
    That can be done by using .map() function. See the documentation for more information about this function.

    There is it:
    https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438091/Array+Functions+and+Properties#ArrayFunctionsandProperties-map

    if it’s array of strings you can write $array.map(x => x.replaceAll('/', '')).

    Maybe you have array of objects and in that object you have field from which you want to remove the ‘/’, than you just need to map the field in that object.

    Like that $array.map(x => x.field.replaceAll('/', ''))