Page 1 of 1

[SOLVED]Remove Quotes from Textfile

Posted: Wed Nov 20, 2019 8:44 am
by trach
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.

Re: Remove Quotes from Textfile

Posted: Wed Nov 20, 2019 9:03 am
by freddyp
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,'');

Re: Remove Quotes from Textfile

Posted: Wed Nov 20, 2019 9:55 am
by trach
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.