[SOLVED]Remove Quotes from Textfile

Post Reply
trach
Newbie
Posts: 2
Joined: Tue Nov 19, 2019 11:34 am

[SOLVED]Remove Quotes from Textfile

Post by trach » Wed Nov 20, 2019 8:44 am

Good morning,
is there any chance removing all quotes from a textfile using the switch script element?
I´ve found a script part already but it is just removing the first quotes of the first line of a file.

Code: Select all

var extension = s.getPropertyValue("Extension");
var tempFile = job.createPathWithExtension(extension);
var myFile = new File(tempFile);
var InputPath = job.getPath();
var inputFileText = File.read(InputPath);
var outputFileText = inputFileText.replace('"','');
myFile.open( File.WriteOnly | File.Truncate );
myFile.write(outputFileText);
myFile.close();
job.sendToSingle(tempFile);
job.sendToNull(InputPath);
...but i want to get removed all of them in a multiline document.

greetings.
Last edited by trach on Wed Nov 20, 2019 9:55 am, edited 1 time in total.

freddyp
Advanced member
Posts: 462
Joined: Thu Feb 09, 2012 3:53 pm

Re: Remove Quotes from Textfile

Post by freddyp » Wed Nov 20, 2019 9:03 am

Instead of using a string to be replaced you should use a global regular expression to be replaced:

Code: Select all

var outputFileText = inputFileText.replace(/\"/g,'');

trach
Newbie
Posts: 2
Joined: Tue Nov 19, 2019 11:34 am

Re: Remove Quotes from Textfile

Post by trach » Wed Nov 20, 2019 9:55 am

freddyp wrote:
Wed Nov 20, 2019 9:03 am
Instead of using a string to be replaced you should use a global regular expression to be replaced:

Code: Select all

var outputFileText = inputFileText.replace(/\"/g,'');
Works like a charm.
Thank you freddyp.

Post Reply