const tableList = [
"account.t_account",
"account.t_account_ext",
"account.t_sub_account",
"account.t_sub_account_.*",
"account.account.t_sub_account",
"t_sub_accountok"
]
const databaseList = [
"account"
]
js:求一个数据处理方法,例如上述例子, tableList处理之后,可以得到
[
"t_account",
"t_account_ext",
"t_sub_account",
"t_sub_account_.*"
"t_sub_account",
"t_sub_accountok"
]
之前有如下方案
function format() {
const formattedTableList = [];
for (let i = 0; i < tableList.length; i++) {
const tableName = tableList[i].split('.');
formattedTableList.push(tableName);
}
return formattedTableList.filter((item) => item !== '.');
}
但是不能兼容account.t_sub_account_.*的场景,哪位大佬可以帮忙完善下吗?
这不需要正则表达式吧,直接用 replace都行