Question

Javascript Code Replace Whole Words

  • 20 October 2022
  • 1 reply
  • 122 views

Hi I am trying to replace whole words in my data set using Javascript in Code by Zapier, in this case replacing field contents that only have ‘t’s with blank data…..but I don’t want to effect words so that my name for example goes from ‘Tom’ to ‘om’.

My coding is:

Let Set = inputData.Set.replace("\\bt\\b", "");

output = [{Set}];

 

 

When I run the above it spits out:

 

Set

t,t,t,20/10/2022,20/10/2022,16/08/2022,01/10/2022,Rob,Colin,b,a,1500,Bowen,RD,ssddd,,,ss,,c,d,ddd,,11am,xx,yy

id

2N7dw58oz5yqnEjhRYK3v4ycktexzCTi

runtime_meta

memory_used_mb

62

duration_ms

14

logs

async

false

 

What am I doing wrong?  It doesn’t spit out outcomes nor take away the ‘t’s


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 1
Badge

Hi @TimC 

What I understand is you want to replace only “t”s with blank values, not “t”s in the words. So the output you’re looking for should be the following.

,,,20/10/2022,20/10/2022,16/08/2022,01/10/2022,Rob,Colin,b,a,1500,Bowen,RD,ssddd,,,ss,,c,d,ddd,,11am,xx,yy

Is that correct?