param keySchema param interpolations returns { * export function buildRegexForKeyMatch ( keySchema , interpolations ) { const varsPattern = interpolations . join ( '|' ) ; const keysMatcher = new RegExp ( `\\{{(${ varsPattern })\\}}` , 'gm' ) ; const keys = [ ] as string [ ] ; keySchema = keySchema . replace ( keysMatcher , substr => { const matchKey = ( substr . match ( /\{{(.+?)\}}/ ) ?? [ ] ) [ 1 ] ; keys . push ( matchKey ) ; return '(.*)' ; } ) ; return { exp : new RegExp ( `^${ keySchema }` , 'gm' ) , keys , } ; }