Use a var in a Reg Exp? Use expression in .split(var).join(var)?

Hello everyone - this is my very first post here, so I’ll try to keep it short and sweet:

I made this line of code:

Imput.text = Imput.text.split(LastSelectedCommand).join(CommandList.selectedItem.data);

However, I need it to search only once and at the very beginning of Imput.text. Using ^ in a regular expression should work, however, I have not been able to figure out how to use a variable’s value in a reg exp.

Any help will be greatly appreciated, thank you.