0

Im trying to replace special character with null within SSJS. here is what i tried:

    <script runat="server">
     Platform.Load("core","1.1.5");
        var listingPrice1 = '$123,456,00';
        listingPrice1 = listingPrice1.replace(',', '').replace('.', '');
    </script>

however, there is an error pop out:

Object expected: replace Line: 16 Char: 3 listingPrice1 = listingPrice1.replace(',', '').replace('.', '')
Exception of type 'Jint.Native.JsException' was thrown.

is ssjs not support replace()?

1
  • try writing your replace() function in 2 separate lines – Abhishek Oct 21 '20 at 8:05
0

You can do a replace with standard JS; the below code should get you where you want to be!

 <script runat="server">
Platform.Load("core","1.1.5");
     
   var listingPrice1 = '$123,456,00';
   var listingPriceFinal = listingPrice1.replace(/[,\.]/gi, "");

   Write(listingPriceFinal);
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.