[英]Format phone number string from google form to spreadsheets into an email draft using google script
For the most part of this code I have down. 在这段代码的大部分时间内,我都很失望。 The only issue I am having is formatting a phone number that has been inputted to the Google Form. 我唯一遇到的问题是格式化输入到Google表单中的电话号码。 On the Spreadsheet the values come in looking like 1234567890, just a string of numbers. 在电子表格上,值看起来像1234567890,只是一串数字。 I am using body.replaceText("%PHONE1%", row[2]);
我正在使用body.replaceText("%PHONE1%", row[2]);
to replace %PHONE1% in the template document. 替换模板文档中的%PHONE1%。 Issue is it numbers come in the same as the spreadsheet 1234567890 and I want the phone number to look like (123) 456-7890. 问题是号码与电子表格1234567890相同,我希望电话号码看起来像(123)456-7890。 It may possibly something like 它可能像
Utilities.formatString('%11.6f', 123.456); Utilities.formatString('%11.6f',123.456);
Please help, im a super newb at any type of scripting any help would be appreciated. 请帮忙,在任何类型的脚本编写上都是超级新手,将不胜感激。 Thank you 谢谢
Here's a simple example: 这是一个简单的例子:
function formatPhoneNumber()
{
var s='1234567890';
if(s)
{
var mA=s.match(/(\d{3})(\d{3})(\d{4})/);
var s=Utilities.formatString('(%s) %s-%s', mA[1],mA[2],mA[3]);
var ui=HtmlService.createHtmlOutput(s);
SpreadsheetApp.getUi().showModelessDialog(ui, 'Phone Number')
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.