Mathavan Krishnan
Mathavan Krishnan

Reputation: 149

Using formula in Google sheet using Google App Script

I have a formula as follows to be included in Google sheet

paypalPayment.getRange("A2").setFormula('=FILTER(USERNAMES!I:I, VALUE(REGEXEXTRACT(B4, "(\d+)")) = USERNAMES!B:B, "JALAN SANGGUL " & REGEXEXTRACT(B4, "\d{1,3}.+(\d)") = USERNAMES!C:C)');

If I use this formula in google sheet, there is no problem, the formula is working fine but when I use it in google app script the \d becomes d automatically in google sheets, I am not sure with the problem but can anyone help me with it?

Upvotes: 0

Views: 131

Answers (1)

Kin Siang
Kin Siang

Reputation: 2699

Try this, in Javascrip language, \ is consider as escape function, in order for your scrip tto write value start with \ correctly, you need to escape , therefore the answer is \d

paypalPayment.getRange("A2").setFormula('=FILTER(USERNAMES!I:I, VALUE(REGEXEXTRACT(B4, "(\\d+)")) = USERNAMES!B:B, "JALAN SANGGUL " & REGEXEXTRACT(B4, "\\d{1,3}.+(\\d)") = USERNAMES!C:C)')

Upvotes: 1

Related Questions