javascript - Replace special characters different variables -
i'm trying put firstname + lastname
email address, , works, need replace special characters in firstname
, lastname
or in finished variable emailad
:
function createemailaddress(){ var ss = spreadsheetapp.getactivespreadsheet(), sheet = ss.getactivesheet(), range = sheet.getdatarange(), values = range.getvalues(); (var r=1; r<values.length; r++) { var row = values[r], firstname = row[0], lastname = row[1], email = row[2]; if(email != "nodata" ){ var emailad = (firstname + "." + lastname + "@superenterprisecompany.com"); logger.log(emailad); sheet.getrange(1 + r, 3).setvalue(emailad); } } }
i found this, not know how work variables
function convert_accented_characters(str){ var conversions = new object(); conversions['ae'] = 'ä|æ|ǽ'; conversions['oe'] = 'ö|œ'; conversions['ue'] = 'ü'; conversions['ae'] = 'Ä'; conversions['ue'] = 'Ü'; conversions['oe'] = 'Ö'; conversions['a'] = 'À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ'; conversions['a'] = 'à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª'; conversions['c'] = 'Ç|Ć|Ĉ|Ċ|Č'; conversions['c'] = 'ç|ć|ĉ|ċ|č'; conversions['d'] = 'Ð|Ď|Đ'; conversions['d'] = 'ð|ď|đ'; conversions['e'] = 'È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě'; conversions['e'] = 'è|é|ê|ë|ē|ĕ|ė|ę|ě'; conversions['g'] = 'Ĝ|Ğ|Ġ|Ģ'; conversions['g'] = 'ĝ|ğ|ġ|ģ'; conversions['h'] = 'Ĥ|Ħ'; conversions['h'] = 'ĥ|ħ'; conversions['i'] = 'Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ'; conversions['i'] = 'ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı'; conversions['j'] = 'Ĵ'; conversions['j'] = 'ĵ'; conversions['k'] = 'Ķ'; conversions['k'] = 'ķ'; conversions['l'] = 'Ĺ|Ļ|Ľ|Ŀ|Ł'; conversions['l'] = 'ĺ|ļ|ľ|ŀ|ł'; conversions['n'] = 'Ñ|Ń|Ņ|Ň'; conversions['n'] = 'ñ|ń|ņ|ň|ʼn'; conversions['o'] = 'Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ'; conversions['o'] = 'ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º'; conversions['r'] = 'Ŕ|Ŗ|Ř'; conversions['r'] = 'ŕ|ŗ|ř'; conversions['s'] = 'Ś|Ŝ|Ş|Š'; conversions['s'] = 'ś|ŝ|ş|š|ſ'; conversions['t'] = 'Ţ|Ť|Ŧ'; conversions['t'] = 'ţ|ť|ŧ'; conversions['u'] = 'Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ'; conversions['u'] = 'ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ'; conversions['y'] = 'Ý|Ÿ|Ŷ'; conversions['y'] = 'ý|ÿ|ŷ'; conversions['w'] = 'Ŵ'; conversions['w'] = 'ŵ'; conversions['z'] = 'Ź|Ż|Ž'; conversions['z'] = 'ź|ż|ž'; conversions['ae'] = 'Æ|Ǽ'; conversions['ss'] = 'ß'; conversions['ij'] = 'IJ'; conversions['ij'] = 'ij'; conversions['oe'] = 'Œ'; conversions['f'] = 'ƒ'; for(var in conversions){ var re = new regexp(conversions[i],"g"); str = str.replace(re,i); } return str; }
can try one. think should work. please let me know. if not have change convert_accented_characters function.
var emailad = (convert_accented_characters(firstname) + "." + convert_accented_characters(lastname) + "@superenterprisecompany.com")
Comments
Post a Comment