ContributionsMost RecentMost LikesSolutionsReplace parts of string with values from array of objects I need to replace portions of a string with values from an array of objects: Input String: $string1 = 'SELECT * FROM TABLE A WHERE COL1 = #1 AND COL1 = #2;' In the following example I need to replace #1 and #2 with their correlated value from the given_parameters array. Array of replacement values: { "given_parameters": [ { "name": "#1", "value": "A" }, { "name": "#2", "value": "B" }, { "name": "#3", "value": "C" } ] } Additional Notes: There could be n number of portions of a string that need to be replaced by a value from given_parameters (it could be 1, or it could be 20 portions that require replacement). What I have tried: I have tried the following, but the comparison in the arrow function is a mismatched data type as match() is returning an array: $string1.replace(/\#(.*?)[\s]|\#(\w*?);/g,JSON.parse(_application_parameter_json).given_parameters.find(x => x.name == $string1.match(/\#(.*?)[\s]|\#(\w*?);/g))).value) I think this can be down using the map() function, but I haven’t figured it out yet. Any suggestions or feedback is greatly appreciated. Thanks! Re: Escaping Single Quotes in Error Pipeline - Issue @Spiro_Taleski and @dimche.saveski thank you both for your responses. Ultimately JSON.stringify($original).replace( /'/g,“‘’”) fit the bill, as my target was a JSON defined field on a table. Escaping Single Quotes in Error Pipeline - Issue Fairly new SL user here. I am in the process of creating an error pipeline to handle system generated errors that may occur in our pipelines. In this error pipeline we capture the error, error reason, error resolution, snap name, and the original record name/value pairs for all fields on the record that failed to load. We capture this information from the error response JSON array passed from the failed parent pipeline to the error pipeline. See example: [ { "error": "Cannot invoke toExponential() on a function", "stacktrace": "com.snaplogic.snap.api.SnapDataException: Cannot invoke toExponential() on a function\n\tat sl.EvaluatorUtils.methodInternal(EvaluatorUtils.java:903)\n\tat sl.EvaluatorUtils.method(EvaluatorUtils.java:765)\n\tat SC.evaluate(Unknown Source)\n\tat com.snaplogic.util.ExpressionUtils$MyExpressionProperty.eval(ExpressionUtils.java:243)\n\tat com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:989)\n\tat com.snaplogic.snaps.transform.DataTransform.processBinary(DataTransform.java:265)\n\tat com.snaplogic.snaps.transform.DataTransform.process(DataTransform.java:218)\n\tat com.snaplogic.snap.api.ExecutionUtil.process(ExecutionUtil.java:106)\n\tat com.snaplogic.snap.api.ExecutionUtil.executeForDocument(ExecutionUtil.java:118)\n\tat com.snaplogic.snap.api.ExecutionUtil.execute(ExecutionUtil.java:81)\n\tat com.snaplogic.snap.api.SimpleSnap.execute(SimpleSnap.java:70)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.executeSnap(SnapRunnableImpl.java:768)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:550)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:834)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:400)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:116)\n\tat java.base/java.util.concurrent.FutureTask.run(Unknown Source)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)\n\tat java.base/java.util.concurrent.FutureTask.run(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n", "reason": "Functions only have an apply() method", "resolution": "Please check expression syntax and data types.", "status_code": "error", "snap_details": { "label": "Mapper", "instance_id": "1abcdefg2-abc-123a-123b-123abc123abc", "class_id": "com-snaplogic-snaps-transform-datatransform", "build_tag": "snaps12345", "views": { "in": { "input0": { "count": 267 } }, "out": { "output0": { "count": 0 } }, "error": { "error0": { "count": 266 } } } }, "original": { "value": 1266, "field1": "123456", "field2": "NEW YORK", "field3": "NY", "field4": "12345", "field5": "16:00:01", "field6": "AUTOMATION TEST CLIENT", "field8": "123 SESAME ST", "field9": "", "field10": "", "field11": "12/02/2019 00:00:00", "field12": "12/03/0001 00:00:00", "field13": "", "field14": "0", "field15": "0", "field16": "", "field17": "", "field18": "", "field19": "M", "field20": "3", "field21": "SOMEUSR", "field22": "Elmo's Burgers" } } ] Currently I am having an issue with escaping special characters - specifically single quotes (') that are received in the name value pairs for the original. See field 22 in the above example. I have attempted the following to remove them using the replace function: When replace or replaceAll is applied to the $reason and $resolution fields, the single quotation is escaped when we receive them, however when $original.replaceAll(“'”,“‘’”) is used single quotes are not escaped - same results when using JSON.stringify($original).replaceAll(“'”,“‘’”). Any advice on how to escape these single quotes would be greatly appreciated.