OL Learn

Replace All in Designer

Hi trying to replace text within a variable using below code

var Test=GraphicName.replace("%20", " ");

However it is only replacing the first instance, if I use below

var Test=GraphicName.replace("%20", " “).replace(”%20", " ");

It replaces the first and second instance… is there a replaceall function at all? tried this and doesn’t work though I have seen examples… not sure if I’m getting the syntax wrong.

Thanks

Ol

Hi Ol,

Try replacing using regex instead.

var Test=GraphicName.replace(/%20/g, " ");

Regards,
S

Great thanks works!! :slight_smile: