Help with s.replace
Ok so I am concatentating strings together for a full address in two fields. First field is fine, it uses all the fields and works fine. However, in the second address field it will say "SAME AS BLOCK 3" by default but it has my extra commas from my script in it. I am trying s.replace but I don't know what I'm doing and I can't really find anything that solves my problem. I'm not even sure if that is the right code I should be using.
Can someone walk me through my code so I can learn?
var s = this.getField("ADDRESS.1").valueAsString + ", "
+ this.getField("CITY.1").valueAsString + ", "
+ this.getField("COUNTY.1").valueAsString + ", "
+ this.getField("STATE.1").valueAsString + ", "
+ this.getField("COUNTRY.1").valueAsString + ", "
+ this.getField("ZIP.1").valueAsString
event.value = s.replace(/^, |, $/g, "", ', , ');OUTPUT:
SAME AS BLOCK 3, , , ,
What I'm looking for:
SAME AS BLOCK 3
