Hi I have two typescript snippet . both wants to achieve the same . however console.log prints different value. any idea what is wrong? why the code 2 prints false .
var regex1 = new RegExp(/^FEDEX /)
var messagePrefix = "FEDEX "
console.log(regex1.test(messagePrefix)); // this prints true
let messageControlValue:string = "FEDEX "
let regex2:RegExp = new RegExp(/^messageControlValue/);
console.log(regex2.test(messagePrefix)); // this prints false
really appreciatiate any help thanks