This method will strip off curly brackets from the given table name
and replace the percentage character '%' with [[tablePrefix]].
let re = /{{(.*?)}}/g
let str = 'SELECT * FROM {{%user}} FROM WHERE id IN (?)'
let tablePrefix = 'tbl_'
console.log(str.replace(re, '$1').replace('%', tablePrefix))
- INPUT
SELECT * FROM {{%user}} FROM WHERE id IN (?)
- OUTPUT
SELECT * FROM tbl_user FROM WHERE id IN (?)