实现函数template()函数
template('hello ${1}, ${2} is the best ${3}',['world','javascript','language']);
//输出结果
'hello world, javascript is the best language'
function template(str,array){
}
想到用正则表达式提取,但不知道怎么替换到原来的字符串?
实现函数template()函数
template('hello ${1}, ${2} is the best ${3}',['world','javascript','language']);
//输出结果
'hello world, javascript is the best language'
function template(str,array){
}
想到用正则表达式提取,但不知道怎么替换到原来的字符串?
13 回答12.8k 阅读
7 回答1.9k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答873 阅读✓ 已解决
6 回答1k 阅读
2 回答1.3k 阅读✓ 已解决
使用正则表达式进行匹配,如果配置位置对应的索引在数组中没有给出则以?替代