📅  最后修改于: 2022-03-11 15:01:38.808000             🧑  作者: Mango
function alphabet(str) {
let alphabetStr = 'abcdefghijklmnopqrstuvwxyz';
let strRegEx =`[${str[0]}-${str[3]}]`; //set regex with variables
let newRegEx = new RegExp(strRegEx, 'g'); //create new regex object
//regex object pattern is: RegExp(pattern, modifiers)
let charSetStr = alphabetStr.match(newRegEx);
return charSetStr;
}
console.log(alphabet('abce'));
//expected [ 'a', 'b', 'c', 'd', 'e' ]