我对编码很陌生,所以我很感激任何建议或建议。
我有一个规范化标题的脚本,但是,它忽略了开头的数字,我遇到了一个问题,我有多个具有相同标题标题的列,所以我在前面添加了一个数字来区分它们。例如" 1.Project#"
脚本的目的是进行邮件合并。我想知道是否有办法修改它,以便它不会忽略前面的数字?请参阅下面的脚本:
// Normalizes a string, by removing all alphanumeric characters and using mixed case
// to separate words. The output will always start with a lower case letter.
// This function is designed to produce JavaScript object property names.
// Arguments:
// - header: string to normalize
// Examples:
// "First Name" -> "firstName"
// "Market Cap (millions) -> "marketCapMillions
// "1 number at the beginning is ignored" -> "numberAtTheBeginningIsIgnored"
function normalizeHeader(header) {
var key = "";
var upperCase = false;
for (var i = 0; i < header.length; ++i) {
var letter = header[i];
if (letter == " " && key.length > 0) {
upperCase = true;
continue;
}
if (!isAlnum(letter)) {
continue;
}
if (key.length == 0 && isDigit(letter)) {
continue; // first character must be a letter
}
if (upperCase) {
upperCase = false;
key += letter.toUpperCase();
} else {
key += letter.toLowerCase();
}
}
&#13;
提前谢谢!